mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-02 12:02:47 -05:00
First draft of Unicode support in pterm. It's pretty complete: it
does UTF-8 copy and paste (falling back to normal strings if necessary), it understands X font encodings and translates things accordingly so that if you have a Unicode font you can ask for virtually any single-byte encoding and get it (Mac-Roman pterm, anyone?), and so on. There's work left to be done (wide fonts for CJK spring to mind), but I reckon this is a pretty good start. [originally from svn r2395]
This commit is contained in:
45
charset/sbcs.c
Normal file
45
charset/sbcs.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
wchar_t const *table = (wchar_t const *)charset->data;
|
||||
|
||||
UNUSEDARG(state);
|
||||
|
||||
emit(emitctx, table[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)
|
||||
{
|
||||
wchar_t const *table = (wchar_t const *)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 (table[i] == input_chr) {
|
||||
emit(emitctx, i);
|
||||
return;
|
||||
}
|
||||
emit(emitctx, ERROR);
|
||||
}
|
Reference in New Issue
Block a user