1 /* Access functions for JISX0212 conversion.
2 Copyright (C) 1997-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
27 /* Struct for table with indices in mapping table. */
35 /* Conversion table. */
36 extern const struct jisx0212_idx __jisx0212_to_ucs_idx
[];
37 extern const uint16_t __jisx0212_to_ucs
[];
39 extern const struct jisx0212_idx __jisx0212_from_ucs_idx
[];
40 extern const char __jisx0212_from_ucs
[][2];
43 static inline uint32_t
44 __attribute ((always_inline
))
45 jisx0212_to_ucs4 (const unsigned char **s
, size_t avail
, unsigned char offset
)
47 const struct jisx0212_idx
*rp
= __jisx0212_to_ucs_idx
;
48 unsigned char ch
= *(*s
);
53 if (ch
< offset
|| (ch
- offset
) < 0x22 || (ch
- offset
) > 0x6d)
54 return __UNKNOWN_10646_CHAR
;
60 if (ch2
< offset
|| (ch2
- offset
) <= 0x20 || (ch2
- offset
) >= 0x7f)
61 return __UNKNOWN_10646_CHAR
;
63 idx
= (ch
- offset
- 0x21) * 94 + (ch2
- offset
- 0x21);
68 wch
= __jisx0212_to_ucs
[rp
->idx
+ idx
- rp
->start
];
73 wch
= __UNKNOWN_10646_CHAR
;
80 __attribute ((always_inline
))
81 ucs4_to_jisx0212 (uint32_t wch
, unsigned char *s
, size_t avail
)
83 const struct jisx0212_idx
*rp
= __jisx0212_from_ucs_idx
;
84 unsigned int ch
= (unsigned int) wch
;
88 return __UNKNOWN_10646_CHAR
;
92 cp
= __jisx0212_from_ucs
[rp
->idx
+ ch
- rp
->start
];
94 return __UNKNOWN_10646_CHAR
;
97 return __UNKNOWN_10646_CHAR
;
100 assert (cp
[1] != '\0');
108 #endif /* jis0212.h */