io.encodings.japanese eucjp encode-char working...
parent
f4c5412337
commit
43fc1d7029
|
@ -103,31 +103,24 @@ VALUE: euc-0212-table
|
||||||
[ euc-0201-table u>n ]
|
[ euc-0201-table u>n ]
|
||||||
[ euc-0208-table u>n ]
|
[ euc-0208-table u>n ]
|
||||||
[ euc-0212-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
|
tri 3array harvest
|
||||||
dup length zero?
|
dup length zero?
|
||||||
[ drop replacement-char ]
|
[ drop f ]
|
||||||
[ first ]
|
[ first ] if ;
|
||||||
if ;
|
|
||||||
|
|
||||||
|
|
||||||
M: eucjp encode-char ( c stream encoding -- )
|
M: eucjp encode-char ( c stream encoding -- )
|
||||||
drop
|
drop
|
||||||
[let | stream [ ]
|
[let | stream [ ]
|
||||||
c [ ] |
|
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 stream stream-write1
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
c unicode>eucjp
|
c unicode>eucjp
|
||||||
|
HEX: 8080 +
|
||||||
h>b/b 2byte-array stream stream-write
|
h>b/b 2byte-array stream stream-write
|
||||||
]
|
]
|
||||||
if
|
if
|
||||||
|
@ -155,8 +148,10 @@ M: eucjp decode-char ( stream encoding -- char/f )
|
||||||
! 0208, 0212
|
! 0208, 0212
|
||||||
c1 c2 2byte-array be> HEX: 8080 -
|
c1 c2 2byte-array be> HEX: 8080 -
|
||||||
[ euc-0208-table n>u ]
|
[ euc-0208-table n>u ]
|
||||||
[ euc-0212-table n>u ] bi 2array harvest first
|
[ euc-0212-table n>u ] bi 2array harvest
|
||||||
[ replacement-char ] unless*
|
dup length zero?
|
||||||
|
[ drop replacement-char ]
|
||||||
|
[ first ] if
|
||||||
] if
|
] if
|
||||||
]
|
]
|
||||||
[ replacement-char ] if
|
[ replacement-char ] if
|
||||||
|
|
Loading…
Reference in New Issue