2 * sbcs.c - routines to handle single-byte character sets.
\r
6 #include "internal.h"
\r
9 * The charset_spec for any single-byte character set should
\r
10 * provide read_sbcs() as its read function, and its `data' field
\r
11 * should be a wchar_t string constant containing the 256 entries
\r
12 * of the translation table.
\r
15 void read_sbcs(charset_spec const *charset, long int input_chr,
\r
16 charset_state *state,
\r
17 void (*emit)(void *ctx, long int output), void *emitctx)
\r
19 const struct sbcs_data *sd = charset->data;
\r
23 emit(emitctx, sd->sbcs2ucs[input_chr]);
\r
26 void write_sbcs(charset_spec const *charset, long int input_chr,
\r
27 charset_state *state,
\r
28 void (*emit)(void *ctx, long int output), void *emitctx)
\r
30 const struct sbcs_data *sd = charset->data;
\r
36 * Binary-search in the ucs2sbcs table.
\r
42 c = sd->ucs2sbcs[k];
\r
43 if (input_chr < sd->sbcs2ucs[c])
\r
45 else if (input_chr > sd->sbcs2ucs[c])
\r
52 emit(emitctx, ERROR);
\r