Imports System.Text Imports System.Text.Detail Namespace EncodingTest Sub TestMain() 'abcƒ¿ƒÀƒÁƒAƒCƒEiŠ¿ŽšŠg’£B‚©‚ç3•¶Žšj Dim chars[ELM(15)] = [ &h61, &h62, &h63, &h03b1, &h03b2, &h03b3, &h30a2, &h30a4, &h30a6, &hd840, &hdc00, &hd840, &hdc01, &hd840, &hdc02] As WCHAR Dim utf32bytes[ELM(12)] = [ &h61, &h62, &h63, &h03b1, &h03b2, &h03b3, &h30a2, &h30a4, &h30a6, &h20000, &h20001, &h20002] As DWORD Dim utf8bytes[ELM(30)] = [ &h61, &h62, &h63, &hce, &hb1, &hce, &hb2, &hce, &hb3, &he3, &h82, &ha2, &he3, &h82, &ha4, &he3, &h82, &ha6, &hf0, &ha0, &h80, &h80, &hf0, &ha0, &h80, &h81, &hf0, &ha0, &h80, &h82] As Byte Dim cp932bytes[ELM(15)] = [ &h61, &h62, &h63, &h83, &hbf, &h83, &hc0, &h83, &hc1, &h83, &h41, &h83, &h43, &h83, &h45] As Byte 'Šg’£B‚ÍÈ—ª Dim utf8 = New UTF8Encoding Dim e = utf8.GetEncoder Dim d = utf8.GetDecoder Dim b[256] As Byte Dim u16[256] As WCHAR e.GetBytes(chars, Len(chars) \ SizeOf (WCHAR), b, Len(b), False) UnitTest("UTF8 Encode", memcmp(b, utf8bytes, Len(utf8bytes)) = 0) d.GetChars(utf8bytes, Len(utf8bytes), u16, Len(u16) \ SizeOf (WCHAR), False) UnitTest("UTF8 Decode", memcmp(u16, chars, Len(chars)) = 0) End Sub End Namespace EncodingTest.TestMain()