]>
git.ipfire.org Git - thirdparty/e2fsprogs.git/blob - lib/ext2fs/nls_utf8.c
2 * Copyright (c) 2018 Collabora Ltd.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
17 * This code is adapted from the Linux Kernel. We have a
18 * userspace version here such that the hashes will match that
28 static int utf8_casefold(const struct nls_table
*table
,
29 const unsigned char *str
, size_t len
,
30 unsigned char *dest
, size_t dlen
)
32 const struct utf8data
*data
= utf8nfdicf(table
->version
);
33 struct utf8cursor cur
;
36 if (utf8ncursor(&cur
, data
, str
, len
) < 0)
39 for (nlen
= 0; nlen
< dlen
; nlen
++) {
40 dest
[nlen
] = utf8byte(&cur
);
53 /* Signal invalid sequence */
57 const static struct nls_ops utf8_ops
= {
58 .casefold
= utf8_casefold
,
61 const struct nls_table nls_utf8_12_1
= {
63 .version
= UNICODE_AGE(12, 1, 0),