2018-02-28 13:35:23 -05:00
|
|
|
USING: io io.encodings io.encodings.iana kernel math sequences ;
|
2018-02-28 11:54:50 -05:00
|
|
|
|
|
|
|
IN: io.encodings.latin1
|
|
|
|
|
|
|
|
SINGLETON: latin1
|
|
|
|
|
2018-02-28 13:35:23 -05:00
|
|
|
: latin1-encode ( char -- byte )
|
|
|
|
dup 256 < [ encode-error ] unless ; inline
|
|
|
|
|
2018-02-28 11:54:50 -05:00
|
|
|
M: latin1 encode-char
|
2018-02-28 13:35:23 -05:00
|
|
|
drop [ latin1-encode ] dip stream-write1 ;
|
|
|
|
|
|
|
|
M: latin1 encode-string
|
|
|
|
drop [ [ latin1-encode ] B{ } map-as ] dip stream-write ;
|
2018-02-28 11:54:50 -05:00
|
|
|
|
|
|
|
M: latin1 decode-char
|
|
|
|
drop stream-read1 [
|
|
|
|
dup 256 < [ drop replacement-char ] unless
|
|
|
|
] [ f ] if* ;
|
|
|
|
|
|
|
|
latin1 "ISO_8859-1:1987" register-encoding
|