| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | ! (c)2010 Joe Groff bsd license | 
					
						
							| 
									
										
										
										
											2016-11-09 00:10:58 -05:00
										 |  |  | USING: byte-arrays io.encodings.8-bit.koi8-r | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | 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 | 
					
						
							| 
									
										
										
										
											2016-11-09 00:10:58 -05:00
										 |  |  | { utf16be } [ B{ 0xFE 0xFF 0x00 0x31 0x00 0x32 0x00 0x33 } detect-byte-array ] unit-test | 
					
						
							|  |  |  | { utf16le } [ B{ 0xFF 0xFE 0x31 0x00 0x32 0x00 0x33 0x00 } detect-byte-array ] unit-test | 
					
						
							|  |  |  | { utf32be } [ B{ 0x00 0x00 0xFE 0xFF 0x00 0x00 0x00 0x31 0x00 0x00 0x00 0x32 0x00 0x00 0x00 0x33 } detect-byte-array ] unit-test | 
					
						
							|  |  |  | { utf32le } [ B{ 0xFF 0xFE 0x00 0x00 0x31 0x00 0x00 0x00 0x32 0x00 0x00 0x00 0x33 0x00 0x00 0x00 } detect-byte-array ] unit-test | 
					
						
							|  |  |  | { utf8 } [ B{ 0xEF 0xBB 0xBF 0x31 0x32 0x33 } detect-byte-array ] unit-test | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! XML prolog | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { utf8 } | 
					
						
							| 
									
										
										
										
											2015-07-26 01:59:56 -04:00
										 |  |  | [ "<?xml version=\"1.0\"?>" >byte-array detect-byte-array ] | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { utf8 } | 
					
						
							| 
									
										
										
										
											2015-07-26 01:59:56 -04:00
										 |  |  | [ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" >byte-array detect-byte-array ] | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { latin1 } | 
					
						
							| 
									
										
										
										
											2015-07-26 01:59:56 -04:00
										 |  |  | [ "<?xml version='1.0' encoding='ISO-8859-1'?>" >byte-array detect-byte-array ] | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { latin1 } | 
					
						
							| 
									
										
										
										
											2015-07-26 01:59:56 -04:00
										 |  |  | [ "<?xml version='1.0' encoding=\"ISO-8859-1\" " >byte-array detect-byte-array ] | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Default to utf8 if decoding succeeds and there are no nulls | 
					
						
							| 
									
										
										
										
											2016-11-09 00:10:58 -05:00
										 |  |  | { utf8 } [ B{ } detect-byte-array ] unit-test | 
					
						
							|  |  |  | { utf8 } [ B{ 0x31 0x32 0x33 } detect-byte-array ] unit-test | 
					
						
							|  |  |  | { utf8 } [ B{ 0x31 0x32 0xC2 0xA0 0x33 } detect-byte-array ] unit-test | 
					
						
							|  |  |  | { latin1 } [ B{ 0x31 0x32 0xA0 0x33 } detect-byte-array ] unit-test | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { koi8-r } [ | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |     koi8-r default-8bit-encoding [ | 
					
						
							| 
									
										
										
										
											2016-11-09 00:10:58 -05:00
										 |  |  |         B{ 0x31 0x32 0xA0 0x33 } detect-byte-array | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |     ] with-variable
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-09 00:10:58 -05:00
										 |  |  | { binary } [ B{ 0x31 0x32 0x33 0xC2 0xA0 0x00 } detect-byte-array ] unit-test | 
					
						
							|  |  |  | { binary } [ B{ 0x31 0x32 0x33 0xC2 0xA0 0x00 0x30 } detect-byte-array ] unit-test |