1 ! (c)2010 Joe Groff bsd license
\r
2 USING: byte-arrays byte-arrays.hex io.encodings.8-bit.koi8-r
\r
3 io.encodings.8-bit.latin1 io.encodings.binary
\r
4 io.encodings.detect io.encodings.utf16 io.encodings.utf32
\r
5 io.encodings.utf8 namespaces tools.test ;
\r
6 IN: io.encodings.detect.tests
\r
8 ! UTF encodings with BOMs
\r
9 [ utf16be ] [ HEX{ FEFF 0031 0032 0033 } detect-byte-array ] unit-test
\r
10 [ utf16le ] [ HEX{ FFFE 3100 3200 3300 } detect-byte-array ] unit-test
\r
11 [ utf32be ] [ HEX{ 0000FEFF 00000031 00000032 00000033 } detect-byte-array ] unit-test
\r
12 [ utf32le ] [ HEX{ FFFE0000 31000000 32000000 33000000 } detect-byte-array ] unit-test
\r
13 [ utf8 ] [ HEX{ EF BB BF 31 32 33 } detect-byte-array ] unit-test
\r
17 [ """<?xml version="1.0"?>""" >byte-array detect-byte-array ]
\r
21 [ """<?xml version="1.0" encoding="UTF-8"?>""" >byte-array detect-byte-array ]
\r
25 [ """<?xml version='1.0' encoding='ISO-8859-1'?>""" >byte-array detect-byte-array ]
\r
29 [ """<?xml version='1.0' encoding="ISO-8859-1" """ >byte-array detect-byte-array ]
\r
32 ! Default to utf8 if decoding succeeds and there are no nulls
\r
33 [ utf8 ] [ HEX{ } detect-byte-array ] unit-test
\r
34 [ utf8 ] [ HEX{ 31 32 33 } detect-byte-array ] unit-test
\r
35 [ utf8 ] [ HEX{ 31 32 C2 A0 33 } detect-byte-array ] unit-test
\r
36 [ latin1 ] [ HEX{ 31 32 A0 33 } detect-byte-array ] unit-test
\r
38 koi8-r default-8bit-encoding [
\r
39 HEX{ 31 32 A0 33 } detect-byte-array
\r
43 [ binary ] [ HEX{ 31 32 33 C2 A0 00 } detect-byte-array ] unit-test
\r
44 [ binary ] [ HEX{ 31 32 33 C2 A0 00 30 } detect-byte-array ] unit-test
\r