Incorrect x86 CPU family and model check.
[glibc.git] / iconvdata / jisx0213.h
blob9d50306a682dc56b745a3bbe9e62033357ca103f
1 /* Functions for JISX0213 conversion.
2 Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Bruno Haible <bruno@clisp.org>, 2002.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
21 #ifndef _JISX0213_H
22 #define _JISX0213_H 1
24 #include <stdint.h>
26 extern const uint16_t __jisx0213_to_ucs_combining[][2];
27 extern const uint16_t __jisx0213_to_ucs_main[120 * 94];
28 extern const uint32_t __jisx0213_to_ucs_pagestart[];
29 extern const int16_t __jisx0213_from_ucs_level1[2715];
30 extern const uint16_t __jisx0213_from_ucs_level2[];
32 #define NELEMS(arr) (sizeof (arr) / sizeof (arr[0]))
34 static inline uint32_t
35 __attribute ((always_inline))
36 jisx0213_to_ucs4 (unsigned int row, unsigned int col)
38 uint32_t val;
40 if (row >= 0x121 && row <= 0x17e)
41 row -= 289;
42 else if (row == 0x221)
43 row -= 451;
44 else if (row >= 0x223 && row <= 0x225)
45 row -= 452;
46 else if (row == 0x228)
47 row -= 454;
48 else if (row >= 0x22c && row <= 0x22f)
49 row -= 457;
50 else if (row >= 0x26e && row <= 0x27e)
51 row -= 519;
52 else
53 return 0x0000;
55 if (col >= 0x21 && col <= 0x7e)
56 col -= 0x21;
57 else
58 return 0x0000;
60 val = __jisx0213_to_ucs_main[row * 94 + col];
61 val = __jisx0213_to_ucs_pagestart[val >> 8] + (val & 0xff);
62 if (val == 0xfffd)
63 val = 0x0000;
64 return val;
67 static inline uint16_t
68 __attribute ((always_inline))
69 ucs4_to_jisx0213 (uint32_t ucs)
71 if (ucs < NELEMS (__jisx0213_from_ucs_level1) << 6)
73 int index1 = __jisx0213_from_ucs_level1[ucs >> 6];
74 if (index1 >= 0)
75 return __jisx0213_from_ucs_level2[(index1 << 6) + (ucs & 0x3f)];
77 return 0x0000;
80 static inline int
81 __attribute ((always_inline))
82 jisx0213_added_in_2004_p (uint16_t val)
84 /* From JISX 0213:2000 to JISX 0213:2004, 10 characters were added to
85 plane 1, and plane 2 was left unchanged. See ISO-IR-233. */
86 switch (val >> 8)
88 case 0x2e:
89 return val == 0x2e21;
90 case 0x2f:
91 return val == 0x2f7e;
92 case 0x4f:
93 return val == 0x4f54 || val == 0x4f7e;
94 case 0x74:
95 return val == 0x7427;
96 case 0x7e:
97 return val >= 0x7e7a && val <= 0x7e7e;
98 default:
99 return 0;
103 #endif /* _JISX0213_H */