]> gitweb.factorcode.org Git - factor.git/commitdiff
io.encodings.japanese eucjp encode-char working...
authorYun, Jonghyouk <ageldama@gmail.com>
Sun, 1 Mar 2009 14:49:33 +0000 (23:49 +0900)
committerYun, Jonghyouk <ageldama@gmail.com>
Sun, 1 Mar 2009 14:49:33 +0000 (23:49 +0900)
basis/io/encodings/japanese/japanese.factor

index 13cea39c69667f0061891c0ab701dfee65ea371f..b3979dd2d382315b07ca2a1e5c6feb84ee7fa6d8 100644 (file)
@@ -103,31 +103,24 @@ VALUE: euc-0212-table
     [ euc-0201-table u>n ]
     [ euc-0208-table u>n ]
     [ euc-0212-table u>n ]
-    tri 3array harvest first
-    ;
-
-:: eucjp>unicode ( n -- u )
-    n
-    [ euc-0201-table n>u ]
-    [ euc-0208-table n>u ]
-    [ euc-0212-table n>u ]
     tri 3array harvest
     dup length zero?
-    [ drop replacement-char ]
-    [ first ]
-    if ;
-
+    [ drop f ]
+    [ first ] if ;
 
 M: eucjp encode-char ( c stream encoding -- )
     drop
     [let | stream [ ]
            c [ ] |
-        c unicode>eucjp small?
+        c unicode>eucjp [ c ] unless*
+        ! FIXME: ???
+        drop t ! ascii? ! ] [ HEX: 20 HEX: 7E between? ] bi or
         [
             c stream stream-write1
         ]
         [
             c unicode>eucjp
+            HEX: 8080 +
             h>b/b 2byte-array stream stream-write
         ]
         if
@@ -155,8 +148,10 @@ M: eucjp decode-char ( stream encoding -- char/f )
                         ! 0208, 0212
                         c1 c2 2byte-array be> HEX: 8080 -
                         [ euc-0208-table n>u ]
-                        [ euc-0212-table n>u ] bi 2array harvest first
-                        [ replacement-char ] unless*
+                        [ euc-0212-table n>u ] bi 2array harvest
+                        dup length zero?
+                        [ drop replacement-char ]
+                        [ first ] if
                     ] if
                 ]
                 [ replacement-char ] if