Ignore:
Timestamp:
Feb 16, 2009, 4:26:24 PM (16 years ago)
Author:
イグトランス (egtra)
Message:

UTF8Encodingクラスをとりあえず使える状態に。ただし、BOM出力はまだ不可能。
(#231)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/TestCase/SimpleTestCase/EncodingTest.ab

    r653 r682  
    11Imports System.Text
    22Imports System.Text.Detail
    3 /*
     3
    44Namespace EncodingTest
    55
     
    2727
    2828    Dim utf8 = New UTF8Encoding
    29     Dim e = utf8.GetEncoder
    30     Dim d = utf8.GetDecoder
     29    Dim e = utf8.GetEncoder()
     30    Dim d = utf8.GetDecoder()
    3131    Dim b[256] As Byte
    3232    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)
     33    Dim len As Long
     34
     35    len = utf8.GetBytesCount(chars, Len(chars) \ SizeOf(WCHAR))
     36    UnitTest("UTF-8 GetByteCount", len = Len(utf8bytes))
     37    utf8.GetBytes(chars, Len(chars) \ SizeOf (WCHAR), b, Len(b))
     38    UnitTest("UTF-8 Encode", memcmp(b, utf8bytes, Len(utf8bytes)) = 0)
     39
     40    len = utf8.GetCharsCount(utf8bytes, Len(utf8bytes))
     41    UnitTest("UTF-8 GetCharCount", len = Len(chars) \ SizeOf(WCHAR))
     42    utf8.GetChars(utf8bytes, Len(utf8bytes), u16, Len(u16) \ SizeOf (WCHAR))
     43    UnitTest("UTF-8 Decode", memcmp(u16, chars, Len(chars)) = 0)
    3744End Sub
    3845
     
    4047
    4148EncodingTest.TestMain()
    42 */
     49
Note: See TracChangeset for help on using the changeset viewer.