io.encodings: allow encode-string to be called with non-strings.
parent
b0e6796a95
commit
0988df1e5a
|
@ -2,7 +2,8 @@
|
|||
! 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
|
||||
|
@ -115,13 +116,13 @@ M: utf16le encode-char ( char stream encoding -- )
|
|||
|
||||
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 ;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! 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
|
||||
|
@ -86,7 +86,7 @@ M: utf8 encode-char
|
|||
|
||||
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 ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue