1 ! Copyright (C) 2008 Daniel Ehrenberg.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors byte-arrays io io.encodings
4 io.encodings.private kernel math sequences strings ;
11 over 127 <= [ stream-write1 ] [ throw-encode-error ] if ; inline
15 GENERIC: ascii> ( string -- byte-array )
19 [ [ dup 127 <= [ throw-encode-error ] unless ] B{ } map-as ]
20 [ string>byte-array-fast ] if ; inline
24 M: ascii encode-string
26 [ ascii> ] dip stream-write ;
31 dup 127 <= [ >fixnum ] [ drop replacement-char ] if
34 M: ascii decode-until (decode-until) ;