4 #include <linux/init.h>
6 /* Unicode has changed over the years. Unicode code points no longer
7 * fit into 16 bits; as of Unicode 5 valid code points range from 0
8 * to 0x10ffff (17 planes, where each plane holds 65536 code points).
10 * The original decision to represent Unicode characters as 16-bit
11 * wchar_t values is now outdated. But plane 0 still includes the
12 * most commonly used characters, so we will retain it. The newer
13 * 32-bit unicode_t type can be used when it is necessary to
14 * represent the full Unicode character set.
17 /* Plane-0 Unicode character */
19 #define MAX_WCHAR_T 0xffff
21 /* Arbitrary Unicode character */
22 typedef u32 unicode_t
;
27 int (*uni2char
) (wchar_t uni
, unsigned char *out
, int boundlen
);
28 int (*char2uni
) (const unsigned char *rawstring
, int boundlen
,
30 const unsigned char *charset2lower
;
31 const unsigned char *charset2upper
;
33 struct nls_table
*next
;
36 /* this value hold the maximum octet of charset */
37 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
39 /* Byte order for UTF-16 strings */
47 extern int register_nls(struct nls_table
*);
48 extern int unregister_nls(struct nls_table
*);
49 extern struct nls_table
*load_nls(char *);
50 extern void unload_nls(struct nls_table
*);
51 extern struct nls_table
*load_nls_default(void);
53 extern int utf8_to_utf32(const u8
*s
, int len
, unicode_t
*pu
);
54 extern int utf32_to_utf8(unicode_t u
, u8
*s
, int maxlen
);
55 extern int utf8s_to_utf16s(const u8
*s
, int len
, wchar_t *pwcs
);
56 extern int utf16s_to_utf8s(const wchar_t *pwcs
, int len
,
57 enum utf16_endian endian
, u8
*s
, int maxlen
);
59 static inline unsigned char nls_tolower(struct nls_table
*t
, unsigned char c
)
61 unsigned char nc
= t
->charset2lower
[c
];
66 static inline unsigned char nls_toupper(struct nls_table
*t
, unsigned char c
)
68 unsigned char nc
= t
->charset2upper
[c
];
73 static inline int nls_strnicmp(struct nls_table
*t
, const unsigned char *s1
,
74 const unsigned char *s2
, int len
)
77 if (nls_tolower(t
, *s1
++) != nls_tolower(t
, *s2
++))
85 * nls_nullsize - return length of null character for codepage
86 * @codepage - codepage for which to return length of NULL terminator
88 * Since we can't guarantee that the null terminator will be a particular
89 * length, we have to check against the codepage. If there's a problem
90 * determining it, assume a single-byte NULL terminator.
93 nls_nullsize(const struct nls_table
*codepage
)
96 char tmp
[NLS_MAX_CHARSET_SIZE
];
98 charlen
= codepage
->uni2char(0, tmp
, NLS_MAX_CHARSET_SIZE
);
100 return charlen
> 0 ? charlen
: 1;
103 #define MODULE_ALIAS_NLS(name) MODULE_ALIAS("nls_" __stringify(name))
105 #endif /* _LINUX_NLS_H */
This page took 0.031414 seconds and 5 git commands to generate.