2015-06-29 19:43:15 -04:00
|
|
|
! (c)2010 Joe Groff bsd license
|
|
|
|
USING: byte-arrays byte-arrays.hex io.encodings.8-bit.koi8-r
|
|
|
|
io.encodings.8-bit.latin1 io.encodings.binary
|
|
|
|
io.encodings.detect io.encodings.utf16 io.encodings.utf32
|
|
|
|
io.encodings.utf8 namespaces tools.test ;
|
|
|
|
IN: io.encodings.detect.tests
|
|
|
|
|
|
|
|
! UTF encodings with BOMs
|
2015-07-02 16:37:42 -04:00
|
|
|
[ utf16be ] [ HEX{ FEFF 0031 0032 0033 } detect-byte-array ] unit-test
|
|
|
|
[ utf16le ] [ HEX{ FFFE 3100 3200 3300 } detect-byte-array ] unit-test
|
|
|
|
[ utf32be ] [ HEX{ 0000FEFF 00000031 00000032 00000033 } detect-byte-array ] unit-test
|
|
|
|
[ utf32le ] [ HEX{ FFFE0000 31000000 32000000 33000000 } detect-byte-array ] unit-test
|
|
|
|
[ utf8 ] [ HEX{ EF BB BF 31 32 33 } detect-byte-array ] unit-test
|
2015-06-29 19:43:15 -04:00
|
|
|
|
|
|
|
! XML prolog
|
2015-07-02 16:37:42 -04:00
|
|
|
[ utf8 ]
|
2015-06-29 19:43:15 -04:00
|
|
|
[ """<?xml version="1.0"?>""" >byte-array detect-byte-array ]
|
|
|
|
unit-test
|
|
|
|
|
2015-07-02 16:37:42 -04:00
|
|
|
[ utf8 ]
|
2015-06-29 19:43:15 -04:00
|
|
|
[ """<?xml version="1.0" encoding="UTF-8"?>""" >byte-array detect-byte-array ]
|
|
|
|
unit-test
|
|
|
|
|
2015-07-02 16:37:42 -04:00
|
|
|
[ latin1 ]
|
2015-06-29 19:43:15 -04:00
|
|
|
[ """<?xml version='1.0' encoding='ISO-8859-1'?>""" >byte-array detect-byte-array ]
|
|
|
|
unit-test
|
|
|
|
|
2015-07-02 16:37:42 -04:00
|
|
|
[ latin1 ]
|
2015-06-29 19:43:15 -04:00
|
|
|
[ """<?xml version='1.0' encoding="ISO-8859-1" """ >byte-array detect-byte-array ]
|
|
|
|
unit-test
|
|
|
|
|
|
|
|
! Default to utf8 if decoding succeeds and there are no nulls
|
2015-07-02 16:37:42 -04:00
|
|
|
[ utf8 ] [ HEX{ } detect-byte-array ] unit-test
|
|
|
|
[ utf8 ] [ HEX{ 31 32 33 } detect-byte-array ] unit-test
|
|
|
|
[ utf8 ] [ HEX{ 31 32 C2 A0 33 } detect-byte-array ] unit-test
|
|
|
|
[ latin1 ] [ HEX{ 31 32 A0 33 } detect-byte-array ] unit-test
|
|
|
|
[ koi8-r ] [
|
2015-06-29 19:43:15 -04:00
|
|
|
koi8-r default-8bit-encoding [
|
|
|
|
HEX{ 31 32 A0 33 } detect-byte-array
|
|
|
|
] with-variable
|
|
|
|
] unit-test
|
|
|
|
|
2015-07-02 16:37:42 -04:00
|
|
|
[ binary ] [ HEX{ 31 32 33 C2 A0 00 } detect-byte-array ] unit-test
|
|
|
|
[ binary ] [ HEX{ 31 32 33 C2 A0 00 30 } detect-byte-array ] unit-test
|