From f4c5412337033328d22a8db32978da6ad0430a88 Mon Sep 17 00:00:00 2001 From: "Yun, Jonghyouk" Date: Sun, 1 Mar 2009 22:54:00 +0900 Subject: [PATCH] io.encodings.japanese eucjp=>decode-char proper working version! --- basis/io/encodings/japanese/japanese.factor | 34 +++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/basis/io/encodings/japanese/japanese.factor b/basis/io/encodings/japanese/japanese.factor index e62a92425f..13cea39c69 100644 --- a/basis/io/encodings/japanese/japanese.factor +++ b/basis/io/encodings/japanese/japanese.factor @@ -4,7 +4,7 @@ USING: sequences kernel io io.files combinators.short-circuit math.order values assocs io.encodings io.binary fry strings math io.encodings.ascii arrays byte-arrays accessors splitting math.parser biassocs io.encodings.iana io.encodings.asian -locals ; +locals multiline combinators ; IN: io.encodings.japanese SINGLETON: shift-jis @@ -136,17 +136,33 @@ M: eucjp encode-char ( c stream encoding -- ) M: eucjp decode-char ( stream encoding -- char/f ) drop [let | stream [ ] - c1! [ 0 ] | + c1! [ 0 ] + c2! [ 0 ] | stream stream-read1 c1! - c1 small? - [ c1 ] + c1 [ - c1 - stream stream-read1 - 2byte-array be> - eucjp>unicode + c1 HEX: 20 HEX: 7E between? + [ c1 euc-0201-table n>u ] + [ + stream stream-read1 c2! + c2 + [ + c1 HEX: 8E = + [ + c2 euc-0201-table n>u + ] ! 0201 + [ + ! 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* + ] if + ] + [ replacement-char ] if + ] if ] - if + [ f ] if ] ;