[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Progress on xterm with combining characters!
Robert Brady wrote on 1999-11-05 22:15 UTC:
> At <http://www.ecs.soton.ac.uk/~rwb197/xterm-patch-0.5.diff.gz> is a patch
> against xterm-120, which improves the UTF-8 support in xterm by adding
> doublewidth characters and combining characters (up to two per base
> character).
Very cool!
Minor fix: My old iswide() routine needs a tiny update, because the
Unicode consortium realized only recently that U+300A, U+300B, U+301A,
U+301B are actually mathematical and not CJK symbols (thanks to Bruno
Haible for pointing this out). The attached updated routine has been
tested against the final Unicode 3.0 EastAsianWidth table. These four
new math characters are now also in TARGET3.
Markus
--
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org, WWW: <http://www.cl.cam.ac.uk/~mgk25/>
/* This function tests, whether the ISO 10646/Unicode character code
* ucs belongs into the East Asian Wide (W) or East Asian FullWidth
* (F) category as defined in Unicode Technical Report #11. In this
* case, the terminal emulator should represent the character using a
* a glyph from a double-wide font that covers two normal (Latin)
* character cells. */
int iswide(int ucs)
{
if (ucs < 0x1100)
return 0;
return
(ucs >= 0x1100 && ucs <= 0x115f) || /* Hangul Jamo */
(ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a &&
ucs != 0x303f) || /* CJK ... Yi */
(ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
(ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
(ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
(ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */
(ucs >= 0xffe0 && ucs <= 0xffe6);
}
/* test routine below */
#include <stdio.h>
#include <ctype.h>
int main()
{
FILE *f;
char line[300], width[3];
int ucs, r;
if (!(f = fopen("EastAsianWidth.txt", "r")))
abort();
while (fgets(line, sizeof(line), f)) {
if (line[0] == '#')
continue;
if (sscanf(line, "%04X;%2s", &ucs, width)
== 2) {
r = !strcmp(width, "W;") || !strcmp(width, "F;");
if (r != iswide(ucs)) {
printf("Mismatch for U+%04X\n", ucs);
}
} else
fprintf(stderr, "Syntax error:\n'%s'\n", line);
}
return 0;
}