'42 30 00 00 A5 33 3F 00 …… ダンプさせる文字列 Dim A As String = ChrW(&H3042) & ChrW(&H0000) & ChrW(&H33A5) & ChrW(&H003F) '82 A0 00 3F 3F …… ChrW(&H33A5) が壊れる System.IO.File.WriteAllText("C:\sjis.txt", A, System.Text.Encoding.GetEncoding("Shift_JIS")) 'FF FE 42 30 00 00 A5 33 3F 00 System.IO.File.WriteAllText("C:\utf16-1.txt", A, System.Text.Encoding.Unicode) '42 30 00 00 A5 33 3F 00 …… 期待する結果に最も近い System.IO.File.WriteAllBytes("C:\utf16-2.txt", System.Text.Encoding.Unicode.GetBytes(A)) '2B 4D 45 49 41 41 44 4F 6C 2D 3F System.IO.File.WriteAllText("C:\utf7.txt", A, System.Text.Encoding.UTF7) 'EF BB BF E3 81 82 00 E3 8E A5 3F System.IO.File.WriteAllText("C:\utf8_1.txt", A, System.Text.Encoding.UTF8) 'E3 81 82 00 E3 8E A5 3F System.IO.File.WriteAllText("C:\utf8_2.txt", A)
Dim S As String = ChrW(&H3042) & ChrW(&H0000) & ChrW(&H33A5) & ChrW(&H003F) ListBox1.DataSource = S.Select(Function(c) String.Format("{0:x4}:{1}", AscW(C), C)).ToList()
Dim S As String = ChrW(&H3042) & ChrW(&H0000) & ChrW(&H33A5) & ChrW(&H003F) ListBox1.DataSource = Array.ConvertAll(Of Char, Integer)(S.ToCharArray(), AddressOf AscW) 'Array.ForEach(Array.ConvertAll(Of Char, Integer)(S.ToCharArray(), AddressOf AscW), AddressOf Console.WriteLine)