FLTK 1.3.4
iso8859_15.h
1 /* $XFree86: xc/lib/X11/lcUniConv/iso8859_15.h,v 1.3 2000/11/29 17:40:31 dawes Exp $ */
2 
3 /*
4  * ISO-8859-15
5  */
6 
7 #ifdef NEED_TOWC
8 static const unsigned short iso8859_15_2uni[32] = {
9  /* 0xa0 */
10  0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x0160, 0x00a7,
11  0x0161, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
12  /* 0xb0 */
13  0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x017d, 0x00b5, 0x00b6, 0x00b7,
14  0x017e, 0x00b9, 0x00ba, 0x00bb, 0x0152, 0x0153, 0x0178, 0x00bf,
15 };
16 
17 static int
18 iso8859_15_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
19 {
20  unsigned char c = *s;
21  if (c >= 0xa0 && c < 0xc0)
22  *pwc = (ucs4_t) iso8859_15_2uni[c-0xa0];
23  else
24  *pwc = (ucs4_t) c;
25  return 1;
26 }
27 #endif /* NEED_TOWC */
28 
29 #ifdef NEED_TOMB
30 static const unsigned char iso8859_15_page00[32] = {
31  0xa0, 0xa1, 0xa2, 0xa3, 0x00, 0xa5, 0x00, 0xa7, /* 0xa0-0xa7 */
32  0x00, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */
33  0xb0, 0xb1, 0xb2, 0xb3, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
34  0x00, 0xb9, 0xba, 0xbb, 0x00, 0x00, 0x00, 0xbf, /* 0xb8-0xbf */
35 };
36 static const unsigned char iso8859_15_page01[48] = {
37  0x00, 0x00, 0xbc, 0xbd, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
38  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
39  0xa6, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
40  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
41  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
42  0xbe, 0x00, 0x00, 0x00, 0x00, 0xb4, 0xb8, 0x00, /* 0x78-0x7f */
43 };
44 
45 static int
46 iso8859_15_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
47 {
48  unsigned char c = 0;
49  if (wc < 0x00a0) {
50  *r = wc;
51  return 1;
52  }
53  else if (wc >= 0x00a0 && wc < 0x00c0)
54  c = iso8859_15_page00[wc-0x00a0];
55  else if (wc >= 0x00c0 && wc < 0x0100)
56  c = wc;
57  else if (wc >= 0x0150 && wc < 0x0180)
58  c = iso8859_15_page01[wc-0x0150];
59  else if (wc == 0x20ac)
60  c = 0xa4;
61  if (c != 0) {
62  *r = c;
63  return 1;
64  }
65  return RET_ILSEQ;
66 }
67 #endif /* NEED_TOMB */