FLTK 1.3.4
iso8859_8.h
1 /* $XFree86: xc/lib/X11/lcUniConv/iso8859_8.h,v 1.3 2000/11/29 17:40:32 dawes Exp $ */
2 
3 /*
4  * ISO-8859-8
5  */
6 
7 #ifdef NEED_TOWC
8 static const unsigned short iso8859_8_2uni[96] = {
9  /* 0xa0 */
10  0x00a0, 0xfffd, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
11  0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
12  /* 0xb0 */
13  0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
14  0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0xfffd,
15  /* 0xc0 */
16  0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
17  0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
18  /* 0xd0 */
19  0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
20  0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x2017,
21  /* 0xe0 */
22  0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
23  0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
24  /* 0xf0 */
25  0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
26  0x05e8, 0x05e9, 0x05ea, 0xfffd, 0xfffd, 0x200e, 0x200f, 0xfffd,
27 };
28 
29 static int
30 iso8859_8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
31 {
32  unsigned char c = *s;
33  if (c >= 0xa0) {
34  unsigned short wc = iso8859_8_2uni[c-0xa0];
35  if (wc != 0xfffd) {
36  *pwc = (ucs4_t) wc;
37  return 1;
38  }
39  }
40  else {
41  *pwc = (ucs4_t) c;
42  return 1;
43  }
44  return RET_ILSEQ;
45 }
46 #endif /* NEED_TOWC */
47 
48 #ifdef NEED_TOMB
49 static const unsigned char iso8859_8_page00[88] = {
50  0xa0, 0x00, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xa0-0xa7 */
51  0xa8, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */
52  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
53  0xb8, 0xb9, 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0x00, /* 0xb8-0xbf */
54  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
55  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
56  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, /* 0xd0-0xd7 */
57  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
58  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
59  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
60  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, /* 0xf0-0xf7 */
61 };
62 static const unsigned char iso8859_8_page05[32] = {
63  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xd0-0xd7 */
64  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xd8-0xdf */
65  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xe0-0xe7 */
66  0xf8, 0xf9, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
67 };
68 static const unsigned char iso8859_8_page20[16] = {
69  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0xfe, /* 0x08-0x0f */
70  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdf, /* 0x10-0x17 */
71 };
72 
73 static int
74 iso8859_8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
75 {
76  unsigned char c = 0;
77  if (wc < 0x00a0) {
78  *r = wc;
79  return 1;
80  }
81  else if (wc >= 0x00a0 && wc < 0x00f8)
82  c = iso8859_8_page00[wc-0x00a0];
83  else if (wc >= 0x05d0 && wc < 0x05f0)
84  c = iso8859_8_page05[wc-0x05d0];
85  else if (wc >= 0x2008 && wc < 0x2018)
86  c = iso8859_8_page20[wc-0x2008];
87  if (c != 0) {
88  *r = c;
89  return 1;
90  }
91  return RET_ILSEQ;
92 }
93 #endif /* NEED_TOMB */