]> gitweb.factorcode.org Git - factor.git/blob - extra/io/encodings/detect/detect-tests.factor
c0d560a2e16ab3f7ff1ae5699502a1f461cf57aa
[factor.git] / extra / io / encodings / detect / detect-tests.factor
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
7 \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
14 \r
15 ! XML prolog\r
16 [ utf8 ]\r
17 [ """<?xml version="1.0"?>""" >byte-array detect-byte-array ]\r
18 unit-test\r
19 \r
20 [ utf8 ]\r
21 [ """<?xml version="1.0" encoding="UTF-8"?>""" >byte-array detect-byte-array ]\r
22 unit-test\r
23 \r
24 [ latin1 ]\r
25 [ """<?xml version='1.0' encoding='ISO-8859-1'?>""" >byte-array detect-byte-array ]\r
26 unit-test\r
27 \r
28 [ latin1 ]\r
29 [ """<?xml version='1.0' encoding="ISO-8859-1" """ >byte-array detect-byte-array ]\r
30 unit-test\r
31 \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
37 [ koi8-r ] [\r
38     koi8-r default-8bit-encoding [\r
39         HEX{ 31 32 A0 33 } detect-byte-array\r
40     ] with-variable\r
41 ] unit-test\r
42 \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
45 \r