1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_UNICODE_H
3 #define _LINUX_UNICODE_H
5 #include <linux/init.h>
6 #include <linux/dcache.h>
11 #define UNICODE_MAJ_SHIFT 16
12 #define UNICODE_MIN_SHIFT 8
14 #define UNICODE_AGE(MAJ, MIN, REV) \
15 (((unsigned int)(MAJ) << UNICODE_MAJ_SHIFT) | \
16 ((unsigned int)(MIN) << UNICODE_MIN_SHIFT) | \
17 ((unsigned int)(REV)))
19 static inline u8 unicode_major(unsigned int age)
21 return (age >> UNICODE_MAJ_SHIFT) & 0xff;
24 static inline u8 unicode_minor(unsigned int age)
26 return (age >> UNICODE_MIN_SHIFT) & 0xff;
29 static inline u8 unicode_rev(unsigned int age)
35 * Two normalization forms are supported:
37 * - Apply unicode normalization form NFD.
38 * - Remove any Default_Ignorable_Code_Point.
40 * - Apply unicode normalization form NFD.
41 * - Remove any Default_Ignorable_Code_Point.
42 * - Apply a full casefold (C + F).
44 enum utf8_normalization {
52 const struct utf8data *ntab[UTF8_NMAX];
53 const struct utf8data_table *tables;
56 int utf8_validate(const struct unicode_map *um, const struct qstr *str);
58 int utf8_strncmp(const struct unicode_map *um,
59 const struct qstr *s1, const struct qstr *s2);
61 int utf8_strncasecmp(const struct unicode_map *um,
62 const struct qstr *s1, const struct qstr *s2);
63 int utf8_strncasecmp_folded(const struct unicode_map *um,
64 const struct qstr *cf,
65 const struct qstr *s1);
67 int utf8_normalize(const struct unicode_map *um, const struct qstr *str,
68 unsigned char *dest, size_t dlen);
70 int utf8_casefold(const struct unicode_map *um, const struct qstr *str,
71 unsigned char *dest, size_t dlen);
73 int utf8_casefold_hash(const struct unicode_map *um, const void *salt,
76 struct unicode_map *utf8_load(unsigned int version);
77 void utf8_unload(struct unicode_map *um);
79 #endif /* _LINUX_UNICODE_H */