From fc1199358c75167e880294a965ad09526664d091 Mon Sep 17 00:00:00 2001 From: "Yun, Jonghyouk" Date: Sat, 28 Feb 2009 15:57:14 +0900 Subject: [PATCH] io.encodings.korean cp949, johab encode-char/decode-char refactoring... --- basis/io/encodings/korean/korean.factor | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/basis/io/encodings/korean/korean.factor b/basis/io/encodings/korean/korean.factor index 95bc1c976b..9df28aa7a8 100644 --- a/basis/io/encodings/korean/korean.factor +++ b/basis/io/encodings/korean/korean.factor @@ -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