aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/nls.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/nls.h')
-rw-r--r--include/linux/nls.h35
1 files changed, 29 insertions, 6 deletions
diff --git a/include/linux/nls.h b/include/linux/nls.h
index 52b1a76c1b43..d47beef08dfd 100644
--- a/include/linux/nls.h
+++ b/include/linux/nls.h
@@ -3,8 +3,23 @@
3 3
4#include <linux/init.h> 4#include <linux/init.h>
5 5
6/* unicode character */ 6/* Unicode has changed over the years. Unicode code points no longer
7typedef __u16 wchar_t; 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).
9 *
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.
15 */
16
17/* Plane-0 Unicode character */
18typedef u16 wchar_t;
19#define MAX_WCHAR_T 0xffff
20
21/* Arbitrary Unicode character */
22typedef u32 unicode_t;
8 23
9struct nls_table { 24struct nls_table {
10 const char *charset; 25 const char *charset;
@@ -21,6 +36,13 @@ struct nls_table {
21/* this value hold the maximum octet of charset */ 36/* this value hold the maximum octet of charset */
22#define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */ 37#define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
23 38
39/* Byte order for UTF-16 strings */
40enum utf16_endian {
41 UTF16_HOST_ENDIAN,
42 UTF16_LITTLE_ENDIAN,
43 UTF16_BIG_ENDIAN
44};
45
24/* nls.c */ 46/* nls.c */
25extern int register_nls(struct nls_table *); 47extern int register_nls(struct nls_table *);
26extern int unregister_nls(struct nls_table *); 48extern int unregister_nls(struct nls_table *);
@@ -28,10 +50,11 @@ extern struct nls_table *load_nls(char *);
28extern void unload_nls(struct nls_table *); 50extern void unload_nls(struct nls_table *);
29extern struct nls_table *load_nls_default(void); 51extern struct nls_table *load_nls_default(void);
30 52
31extern int utf8_mbtowc(wchar_t *, const __u8 *, int); 53extern int utf8_to_utf32(const u8 *s, int len, unicode_t *pu);
32extern int utf8_mbstowcs(wchar_t *, const __u8 *, int); 54extern int utf32_to_utf8(unicode_t u, u8 *s, int maxlen);
33extern int utf8_wctomb(__u8 *, wchar_t, int); 55extern int utf8s_to_utf16s(const u8 *s, int len, wchar_t *pwcs);
34extern int utf8_wcstombs(__u8 *, const wchar_t *, int); 56extern int utf16s_to_utf8s(const wchar_t *pwcs, int len,
57 enum utf16_endian endian, u8 *s, int maxlen);
35 58
36static inline unsigned char nls_tolower(struct nls_table *t, unsigned char c) 59static inline unsigned char nls_tolower(struct nls_table *t, unsigned char c)
37{ 60{