1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00
putty-source/charset/sbcs.c
Ben Harris be63146e4f I have no idea what Simon thought he was doing casting what was once a
struct sbcs_data * (first element an array of unsigned long) into a
wchar_t *, but I think it's reasonably safe to assume that it was a
mistake.

[originally from svn r2399]
2002-12-31 22:37:27 +00:00

46 lines
1.1 KiB
C

/*
* sbcs.c - routines to handle single-byte character sets.
*/
#include "charset.h"
#include "internal.h"
/*
* The charset_spec for any single-byte character set should
* provide read_sbcs() as its read function, and its `data' field
* should be a wchar_t string constant containing the 256 entries
* of the translation table.
*/
void read_sbcs(charset_spec const *charset, long int input_chr,
charset_state *state,
void (*emit)(void *ctx, long int output), void *emitctx)
{
const struct sbcs_data *sd = charset->data;
UNUSEDARG(state);
emit(emitctx, sd->sbcs2ucs[input_chr]);
}
void write_sbcs(charset_spec const *charset, long int input_chr,
charset_state *state,
void (*emit)(void *ctx, long int output), void *emitctx)
{
const struct sbcs_data *sd = charset->data;
int i;
UNUSEDARG(state);
/*
* FIXME: this should work, but it's ludicrously inefficient.
* We should be using the ucs2sbcs table.
*/
for (i = 0; i < 256; i++)
if (sd->sbcs2ucs[i] == input_chr) {
emit(emitctx, i);
return;
}
emit(emitctx, ERROR);
}