io.encodings.8-bit: reimplement M\ 8-bit encode-string.
parent
f43f88e7f0
commit
6d1bb9e1ba
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2008 Daniel Ehrenberg, Doug Coleman.
|
! Copyright (C) 2008 Daniel Ehrenberg, Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays assocs classes.singleton generic
|
USING: accessors arrays assocs classes.singleton fry generic
|
||||||
hashtables io io.encodings io.encodings.iana kernel lexer parser
|
hashtables io io.encodings io.encodings.iana kernel lexer parser
|
||||||
sequences simple-flat-file words ;
|
sequences simple-flat-file words ;
|
||||||
IN: io.encodings.8-bit
|
IN: io.encodings.8-bit
|
||||||
|
@ -22,6 +22,9 @@ TUPLE: 8-bit { from array read-only } { to hashtable read-only } ;
|
||||||
M: 8-bit encode-char
|
M: 8-bit encode-char
|
||||||
swap [ 8-bit-encode ] dip stream-write1 ;
|
swap [ 8-bit-encode ] dip stream-write1 ;
|
||||||
|
|
||||||
|
M: 8-bit encode-string
|
||||||
|
swap [ '[ _ 8-bit-encode ] B{ } map-as ] dip stream-write ;
|
||||||
|
|
||||||
M: 8-bit decode-char
|
M: 8-bit decode-char
|
||||||
swap stream-read1 [
|
swap stream-read1 [
|
||||||
swap from>> ?nth [ replacement-char ] unless*
|
swap from>> ?nth [ replacement-char ] unless*
|
||||||
|
@ -34,8 +37,8 @@ M: 8-bit decode-char
|
||||||
[ create-encoding dup ]
|
[ create-encoding dup ]
|
||||||
[ register-encoding ]
|
[ register-encoding ]
|
||||||
[ encoding-file load-codetable-file <8-bit> ] tri*
|
[ encoding-file load-codetable-file <8-bit> ] tri*
|
||||||
[ [ \ <encoder> create-method ] dip [ nip <encoder> ] curry define ]
|
[ [ \ <encoder> create-method ] dip '[ drop _ <encoder> ] define ]
|
||||||
[ [ \ <decoder> create-method ] dip [ nip <decoder> ] curry define ] 2bi ;
|
[ [ \ <decoder> create-method ] dip '[ drop _ <decoder> ] define ] 2bi ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue