blob: c4d1d3d7a5b114673e9a15a0d66a8642124b7b82 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/*
* KANJI Code conversion routines.
* (for ptex only)
*/
#include "kanji.h"
/* FIXME: why not boolean value */
boolean check_kanji(integer c)
{
/* FIXME: why not 255 (0xff) */
if (0 <= c && c <= 256) return -1; /* ascii without catcode */
if (iskanji1(Hi(c)) && iskanji2(Lo(c))) return 1;
return 0; /* ascii with catcode */
}
boolean is_kanji(integer c)
{
return (iskanji1(Hi(c)) && iskanji2(Lo(c)));
}
boolean is_char_ascii(integer c)
{
return (0 <= c && c < 0x100);
}
boolean is_wchar_ascii(integer c)
{
return (!is_char_ascii(c) && !is_kanji(c));
}
boolean ismultiprn(integer c)
{
if (iskanji1(c) || iskanji2(c)) return true;
return false;
}
#ifdef OLDSTYLE
integer calc_pos(integer c)
{
int c1, c2;
if(c<256) return(c<<1);
c1 = c>>8;
c2 = c & 0xff;
if(c1) {
if (is_internalSJIS())
return((c2+(c2<<(c1-0x81)) & 0xff)<<1);
else
return((c2+(c2<<(c1-0xa1)) & 0xff)<<1);
} else
return(((c2+c2+1) & 0xff)<<1);
}
#else /* OLDSTYLE */
integer calc_pos(integer c)
{
unsigned char c1, c2;
if(c>=0 && c<=255) return(c);
c1 = (c >> 8) & 0xff;
c2 = c & 0xff;
if(iskanji1(c1)) {
if (is_internalSJIS()) {
c1 = ((c1 - 0x81) % 4) * 64; /* c1 = 0, 64, 128, 192 */
c2 = c2 % 64; /* c2 = 0..63 */
} else {
c1 = ((c1 - 0xa1) % 4) * 64; /* c1 = 0, 64, 128, 192 */
c2 = c2 % 64; /* c2 = 0..63 */
}
return(c1 + c2); /* ret = 0..255 */
} else
return(c2);
}
#endif /* OLDSTYLE */
integer kcatcodekey(integer c)
{
return Hi(toDVI(c));
}
|