1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2014 SGI.
10 #include <linux/types.h>
11 #include <linux/export.h>
12 #include <linux/string.h>
13 #include <linux/module.h>
14 #include <linux/unicode.h>
16 int utf8version_is_supported(const struct unicode_map *um, unsigned int version);
19 * Determine the length of the normalized from of the string,
20 * excluding any terminating NULL byte.
21 * Returns 0 if only ignorable code points are present.
22 * Returns -1 if the input is not valid UTF-8.
24 ssize_t utf8nlen(const struct unicode_map *um, enum utf8_normalization n,
25 const char *s, size_t len);
27 /* Needed in struct utf8cursor below. */
28 #define UTF8HANGULLEAF (12)
31 * Cursor structure used by the normalizer.
34 const struct unicode_map *um;
35 enum utf8_normalization n;
44 unsigned char hangul[UTF8HANGULLEAF];
48 * Initialize a utf8cursor to normalize a string.
49 * Returns 0 on success.
50 * Returns -1 on failure.
52 int utf8ncursor(struct utf8cursor *u8c, const struct unicode_map *um,
53 enum utf8_normalization n, const char *s, size_t len);
56 * Get the next byte in the normalization.
57 * Returns a value > 0 && < 256 on success.
58 * Returns 0 when the end of the normalization is reached.
59 * Returns -1 if the string being normalized is not valid UTF-8.
61 extern int utf8byte(struct utf8cursor *u8c);
68 struct utf8data_table {
69 const unsigned int *utf8agetab;
72 const struct utf8data *utf8nfdicfdata;
73 int utf8nfdicfdata_size;
75 const struct utf8data *utf8nfdidata;
76 int utf8nfdidata_size;
78 const unsigned char *utf8data;
81 extern struct utf8data_table utf8_data_table;
83 #endif /* UTF8NORM_H */