|
1 | 1 | using Base.Test
|
2 | 2 | using iconv
|
3 | 3 |
|
4 |
| -for s in ("", "a", "café crème", |
| 4 | +for s in ("", "\0", "a", "café crème", |
5 | 5 | "a"^(iconv.BUFSIZE-1) * "€ with an incomplete codepoint between two input buffer fills",
|
6 |
| - "a string € チャネルパートナーの選択") |
| 6 | + "a string € チャネルパートナーの選択", |
| 7 | + "a string \0€ チャネルパ\0ー\0トナーの選択 with embedded and trailing nuls\0") |
7 | 8 | # Test round-trip to Unicode formats, checking against pure-Julia implementation
|
8 |
| - for T in (UTF8String, UTF16String, UTF32String) |
| 9 | + for (T, nullen) in ((UTF8String, 0), (UTF16String, 2), (UTF32String, 4)) |
9 | 10 | enc = iconv.encoding_string(T)
|
10 | 11 | a = reinterpret(UInt8, T(s).data)
|
| 12 | + # Adjust for explicit \0 only for .data on UTF16String/UTF32String |
| 13 | + a = a[1:end - nullen] |
11 | 14 | @test decode(a, enc) == s
|
12 | 15 | @test decode(encode(s, enc), enc) == s
|
13 | 16 | end
|
|
58 | 61 | # win_iconv currently does not throw an error on bytes >= 0x80 in ASCII sources
|
59 | 62 | # https://github.com/win-iconv/win-iconv/pull/26
|
60 | 63 | if OS_NAME != :Windows
|
61 |
| - @test_throws ErrorException decode("qwertyé€".data, "ASCII") |
| 64 | + @test_throws ErrorException decode(b"qwertyé€", "ASCII") |
62 | 65 | try
|
63 |
| - decode("qwertyé€".data, "ASCII") |
| 66 | + decode(b"qwertyé€", "ASCII") |
64 | 67 | catch err
|
65 | 68 | io = IOBuffer()
|
66 | 69 | showerror(io, err)
|
|
0 commit comments