]> gitweb.factorcode.org Git - factor.git/blobdiff - core/io/encodings/encodings.factor
use radix literals
[factor.git] / core / io / encodings / encodings.factor
index b0244244ae03c25cb39ced7113445fae5e5eaefd..aa5d3af93e0e7ba47b6778991a4edeea93882599 100644 (file)
@@ -23,16 +23,17 @@ M: object encode-string [ encode-char ] 2curry each ; inline
 
 GENERIC: <decoder> ( stream encoding -- newstream )
 
-CONSTANT: replacement-char HEX: fffd
+CONSTANT: replacement-char 0xfffd
 
 TUPLE: decoder { stream read-only } { code read-only } { cr boolean } ;
-INSTANCE: decoder noncopying-reader
+INSTANCE: decoder input-stream
 
 ERROR: decode-error ;
 
 GENERIC: <encoder> ( stream encoding -- newstream )
 
 TUPLE: encoder { stream read-only } { code read-only } ;
+INSTANCE: encoder output-stream
 
 ERROR: encode-error ;
 
@@ -49,14 +50,6 @@ M: object <decoder> f decoder boa ; inline
 : >decoder< ( decoder -- stream encoding )
     [ stream>> ] [ code>> ] bi ; inline
 
-: fix-read1 ( stream char -- char )
-    over cr>> [
-        over cr-
-        dup CHAR: \n = [
-            drop dup stream-read1
-        ] when
-    ] when nip ; inline
-
 M: decoder stream-element-type
     drop +character+ ; inline
 
@@ -92,7 +85,7 @@ M: decoder stream-read1 ( decoder -- ch )
         ] [ (finish-read) ] if*
     ] if ; inline recursive
 
-M: decoder stream-read-unsafe ( n buf decoder -- count )
+M: decoder stream-read-unsafe
     pick 0 = [ 3drop 0 ] [
         (read-first) [
             0 (store-read)
@@ -100,7 +93,8 @@ M: decoder stream-read-unsafe ( n buf decoder -- count )
         ] [ 2drop 2drop 0 ] if*
     ] if ; inline
 
-M: decoder stream-read-partial-unsafe stream-read-unsafe ; inline
+M: decoder stream-contents
+    (stream-contents-by-element) ;
 
 : line-ends/eof ( stream str -- str ) f like swap cr- ; inline