]> gitweb.factorcode.org Git - factor.git/blob - extra/io/encodings/detect/detect-tests.factor
core, basis, extra: Remove DOS line endings from files.
[factor.git] / extra / io / encodings / detect / detect-tests.factor
1 ! (c)2010 Joe Groff bsd license
2 USING: byte-arrays byte-arrays.hex io.encodings.8-bit.koi8-r
3 io.encodings.8-bit.latin1 io.encodings.binary
4 io.encodings.detect io.encodings.utf16 io.encodings.utf32
5 io.encodings.utf8 namespaces tools.test ;
6 IN: io.encodings.detect.tests
7
8 ! UTF encodings with BOMs
9 [ utf16be ] [ HEX{ FEFF 0031 0032 0033 } detect-byte-array ] unit-test
10 [ utf16le ] [ HEX{ FFFE 3100 3200 3300 } detect-byte-array ] unit-test
11 [ utf32be ] [ HEX{ 0000FEFF 00000031 00000032 00000033 } detect-byte-array ] unit-test
12 [ utf32le ] [ HEX{ FFFE0000 31000000 32000000 33000000 } detect-byte-array ] unit-test
13 [ utf8 ] [ HEX{ EF BB BF 31 32 33 } detect-byte-array ] unit-test
14
15 ! XML prolog
16 [ utf8 ]
17 [ """<?xml version="1.0"?>""" >byte-array detect-byte-array ]
18 unit-test
19
20 [ utf8 ]
21 [ """<?xml version="1.0" encoding="UTF-8"?>""" >byte-array detect-byte-array ]
22 unit-test
23
24 [ latin1 ]
25 [ """<?xml version='1.0' encoding='ISO-8859-1'?>""" >byte-array detect-byte-array ]
26 unit-test
27
28 [ latin1 ]
29 [ """<?xml version='1.0' encoding="ISO-8859-1" """ >byte-array detect-byte-array ]
30 unit-test
31
32 ! Default to utf8 if decoding succeeds and there are no nulls
33 [ utf8 ] [ HEX{ } detect-byte-array ] unit-test
34 [ utf8 ] [ HEX{ 31 32 33 } detect-byte-array ] unit-test
35 [ utf8 ] [ HEX{ 31 32 C2 A0 33 } detect-byte-array ] unit-test
36 [ latin1 ] [ HEX{ 31 32 A0 33 } detect-byte-array ] unit-test
37 [ koi8-r ] [
38     koi8-r default-8bit-encoding [
39         HEX{ 31 32 A0 33 } detect-byte-array
40     ] with-variable
41 ] unit-test
42
43 [ binary ] [ HEX{ 31 32 33 C2 A0 00 } detect-byte-array ] unit-test
44 [ binary ] [ HEX{ 31 32 33 C2 A0 00 30 } detect-byte-array ] unit-test
45