]> gitweb.factorcode.org Git - factor.git/blobdiff - core/io/encodings/utf16/utf16.factor
io.encodings.utf16n: merge with io.encodings.utf16
[factor.git] / core / io / encodings / utf16 / utf16.factor
index 2777649aa9d84f328273cd11645a3541907d5c8f..01fc02c1bb499406438a1ec7d32727c4203d3c6e 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2006, 2009 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors byte-arrays io io.encodings kernel math
-math.private sequences sequences.private strings strings.private ;
+USING: accessors alien.accessors byte-arrays io io.encodings
+kernel math math.private sequences sequences.private strings
+strings.private ;
 IN: io.encodings.utf16
 
 SINGLETON: utf16be
@@ -163,3 +164,12 @@ M: utf16 <encoder>
     drop bom-le over stream-write utf16le <encoder> ;
 
 PRIVATE>
+
+SINGLETON: utf16n
+
+: choose-utf16-endian ( -- descriptor )
+    B{ 1 0 0 0 } 0 alien-unsigned-4 1 = utf16le utf16be ? ; foldable
+
+M: utf16n <decoder> drop choose-utf16-endian <decoder> ;
+
+M: utf16n <encoder> drop choose-utf16-endian <encoder> ;