2 * cp949.c - CP949 / KS_C_5601_1987 multibyte encoding
11 * CP949 has no associated data, so `charset' may be ignored.
14 static void read_cp949(charset_spec
const *charset
, long int input_chr
,
16 void (*emit
)(void *ctx
, long int output
), void *emitctx
)
21 * For reading CP949, state->s0 simply contains the single
22 * stored lead byte when we are half way through a double-byte
23 * character, or 0 if we aren't.
27 if (input_chr
>= 0x81 && input_chr
<= 0xFE) {
29 * Lead byte. Just store it.
31 state
->s0
= input_chr
;
34 * Anything else we pass straight through unchanged.
36 emit(emitctx
, input_chr
);
40 * We have a stored lead byte. We expect a valid followup
43 if ((input_chr
>= 0x40 && input_chr
<= 0xFF)) {
44 emit(emitctx
, cp949_to_unicode(state
->s0
- 0x80,
54 * CP949 is a stateless multi-byte encoding (in the sense that just
55 * after any character has been completed, the state is always the
56 * same); hence when writing it, there is no need to use the
60 static int write_cp949(charset_spec
const *charset
, long int input_chr
,
62 void (*emit
)(void *ctx
, long int output
),
69 return TRUE
; /* stateless; no cleanup required */
71 if (input_chr
< 0x80) {
72 emit(emitctx
, input_chr
);
76 if (unicode_to_cp949(input_chr
, &r
, &c
)) {
77 emit(emitctx
, r
+ 0x80);
78 emit(emitctx
, c
+ 0x40);
86 const charset_spec charset_CS_CP949
= {
87 CS_CP949
, read_cp949
, write_cp949
, NULL
90 #else /* ENUM_CHARSETS */
92 ENUM_CHARSET(CS_CP949
)
94 #endif /* ENUM_CHARSETS */