source: trunk/TestCase/SimpleTestCase/EncodingTest.ab@ 451

Last change on this file since 451 was 411, checked in by イグトランス (egtra), 17 years ago

UTF8Encoding(仮)の追加

File size: 1.2 KB
Line 
1Imports System.Text
2Imports System.Text.Detail
3
4Namespace EncodingTest
5
6Sub TestMain()
7 'abcαβγアイウ(漢字拡張Bから3文字)
8 Dim chars[ELM(15)] = [
9 &h61, &h62, &h63,
10 &h03b1, &h03b2, &h03b3,
11 &h30a2, &h30a4, &h30a6,
12 &hd840, &hdc00, &hd840, &hdc01, &hd840, &hdc02] As WCHAR
13 Dim utf32bytes[ELM(12)] = [
14 &h61, &h62, &h63,
15 &h03b1, &h03b2, &h03b3,
16 &h30a2, &h30a4, &h30a6,
17 &h20000, &h20001, &h20002] As DWORD
18 Dim utf8bytes[ELM(30)] = [
19 &h61, &h62, &h63,
20 &hce, &hb1, &hce, &hb2, &hce, &hb3,
21 &he3, &h82, &ha2, &he3, &h82, &ha4, &he3, &h82, &ha6,
22 &hf0, &ha0, &h80, &h80, &hf0, &ha0, &h80, &h81, &hf0, &ha0, &h80, &h82] As Byte
23 Dim cp932bytes[ELM(15)] = [
24 &h61, &h62, &h63,
25 &h83, &hbf, &h83, &hc0, &h83, &hc1,
26 &h83, &h41, &h83, &h43, &h83, &h45] As Byte '拡張Bは省略
27
28 Dim utf8 = New UTF8Encoding
29 Dim e = utf8.GetEncoder
30 Dim d = utf8.GetDecoder
31 Dim b[256] As Byte
32 Dim u16[256] As WCHAR
33 e.GetBytes(chars, Len(chars) \ SizeOf (WCHAR), b, Len(b), False)
34 UnitTest("UTF8 Encode", memcmp(b, utf8bytes, Len(utf8bytes)) = 0)
35 d.GetChars(utf8bytes, Len(utf8bytes), u16, Len(u16) \ SizeOf (WCHAR), False)
36 UnitTest("UTF8 Decode", memcmp(u16, chars, Len(chars)) = 0)
37End Sub
38
39End Namespace
40
41EncodingTest.TestMain()
Note: See TracBrowser for help on using the repository browser.