1 /* Access functions for JISX0212 conversion.
2 Copyright (C) 1997-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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, see
18 <http://www.gnu.org/licenses/>. */
28 /* Struct for table with indeces in mapping table. */
36 /* Conversion table. */
37 extern const struct jisx0212_idx __jisx0212_to_ucs_idx
[];
38 extern const uint16_t __jisx0212_to_ucs
[];
40 extern const struct jisx0212_idx __jisx0212_from_ucs_idx
[];
41 extern const char __jisx0212_from_ucs
[][2];
44 static inline uint32_t
45 __attribute ((always_inline
))
46 jisx0212_to_ucs4 (const unsigned char **s
, size_t avail
, unsigned char offset
)
48 const struct jisx0212_idx
*rp
= __jisx0212_to_ucs_idx
;
49 unsigned char ch
= *(*s
);
54 if (ch
< offset
|| (ch
- offset
) < 0x22 || (ch
- offset
) > 0x6d)
55 return __UNKNOWN_10646_CHAR
;
61 if (ch2
< offset
|| (ch2
- offset
) <= 0x20 || (ch2
- offset
) >= 0x7f)
62 return __UNKNOWN_10646_CHAR
;
64 idx
= (ch
- offset
- 0x21) * 94 + (ch2
- offset
- 0x21);
69 wch
= __jisx0212_to_ucs
[rp
->idx
+ idx
- rp
->start
];
74 wch
= __UNKNOWN_10646_CHAR
;
81 __attribute ((always_inline
))
82 ucs4_to_jisx0212 (uint32_t wch
, unsigned char *s
, size_t avail
)
84 const struct jisx0212_idx
*rp
= __jisx0212_from_ucs_idx
;
85 unsigned int ch
= (unsigned int) wch
;
89 return __UNKNOWN_10646_CHAR
;
93 cp
= __jisx0212_from_ucs
[rp
->idx
+ ch
- rp
->start
];
95 return __UNKNOWN_10646_CHAR
;
98 return __UNKNOWN_10646_CHAR
;
101 assert (cp
[1] != '\0');
109 #endif /* jis0212.h */