! See http://factorcode.org/license.txt for BSD license.
USING: accessors byte-arrays combinators io io.binary
io.encodings kernel math math.private namespaces sbufs
-sequences sequences.private splitting strings.private vectors ;
+sequences sequences.private splitting strings strings.private
+vectors ;
IN: io.encodings.utf16
SINGLETON: utf16be
M: utf16le encode-string
drop
- over aux>>
+ over dup string? [ aux>> ] [ drop t ] if
[ [ char>utf16le ] curry each ]
[ ascii-string>utf16le ] if ;
M: utf16be encode-string
drop
- over aux>>
+ over dup string? [ aux>> ] [ drop t ] if
[ [ char>utf16be ] curry each ]
[ ascii-string>utf16be ] if ;
! Copyright (C) 2006, 2008 Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators io io.encodings
-io.encodings.private kernel math math.order sequences ;
+io.encodings.private kernel math math.order sequences strings ;
IN: io.encodings.utf8
! Decoding UTF-8
M: utf8 encode-string
drop
- over aux>>
+ over dup string? [ aux>> ] [ drop t ] if
[ [ char>utf8 ] curry each ]
[ [ string>byte-array-fast ] dip stream-write ] if ;