]> gitweb.factorcode.org Git - factor.git/commitdiff
io.encodings.korean cp949, johab encode-char/decode-char refactoring...
authorYun, Jonghyouk <ageldama@gmail.com>
Sat, 28 Feb 2009 06:57:14 +0000 (15:57 +0900)
committerYun, Jonghyouk <ageldama@gmail.com>
Sat, 28 Feb 2009 06:57:14 +0000 (15:57 +0900)
basis/io/encodings/korean/korean.factor

index 95bc1c976b218372a406ead28e1370f29405d006..9df28aa7a852c0d52231bde858de18075860287e 100644 (file)
@@ -77,13 +77,22 @@ VALUE: johab-table
     [ HEX: E0 HEX: F9 between? ]
     tri { } 3sequence [ t? ] any? ;
 
-M:: johab encode-char ( char stream encoding -- )
-    char unicode>johab byte?
-    [ char 1byte-array stream stream-write ] [
-        char unicode>johab
+:: encode-char-mb ( c stream quot-conv: ( c -- c2 ) quot-mb?: ( c -- ? ) -- )
+    c quot-conv call quot-mb? call
+    [
+        c quot-conv call
         h>b/b swap 2byte-array
         stream stream-write
-    ] if ;
+    ]
+    [ c 1byte-array stream drop drop
+      stream-write
+    ]
+    if ;
+    
+
+M: johab encode-char ( char stream encoding -- )
+    drop [ unicode>johab ] [ byte? not ] encode-char-mb ;
+
 
 : johab-decode-char-step2 ( c stream -- char )
     stream-read1