diff --git a/extra/io/encodings/detect/detect-tests.factor b/extra/io/encodings/detect/detect-tests.factor index 5dbebd9001..c0d560a2e1 100644 --- a/extra/io/encodings/detect/detect-tests.factor +++ b/extra/io/encodings/detect/detect-tests.factor @@ -30,6 +30,7 @@ unit-test unit-test ! Default to utf8 if decoding succeeds and there are no nulls +[ 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 @@ -41,3 +42,4 @@ unit-test [ 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 + diff --git a/extra/io/encodings/detect/detect.factor b/extra/io/encodings/detect/detect.factor index a803c54c53..c8b01757f8 100644 --- a/extra/io/encodings/detect/detect.factor +++ b/extra/io/encodings/detect/detect.factor @@ -38,6 +38,7 @@ PRIVATE> { [ dup HEX{ EF BB BF } head? ] [ drop utf8 ] } { [ dup $[ "byte-array ] head? ] [ detect-xml-prolog ] } { [ 0 over member? ] [ drop binary ] } + { [ dup empty? ] [ drop utf8 ] } { [ dup valid-utf8? ] [ drop utf8 ] } [ drop default-8bit-encoding get ] } cond ;