| 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* |
| 3 | * Copyright (C) 2018 Ernesto A. Fernández <[email protected]> |
| 4 | */ |
| 5 | |
| 6 | #ifndef _APFS_UNICODE_H |
| 7 | #define _APFS_UNICODE_H |
| 8 | |
| 9 | #include <linux/nls.h> |
| 10 | |
| 11 | /* |
| 12 | * This structure helps apfs_normalize_next() to retrieve one normalized |
| 13 | * (and case-folded) UTF-32 character at a time from a UTF-8 string. |
| 14 | */ |
| 15 | struct apfs_unicursor { |
| 16 | const char *utf8curr; /* Start of UTF-8 to decompose and reorder */ |
| 17 | unsigned int total_len; /* Length of the whole UTF-8 string */ |
| 18 | int length; /* Length of normalization until next starter */ |
| 19 | int last_pos; /* Offset in substring of last char returned */ |
| 20 | u8 last_ccc; /* CCC of the last character returned */ |
| 21 | }; |
| 22 | |
| 23 | extern void apfs_init_unicursor(struct apfs_unicursor *cursor, const char *utf8str, unsigned int total_len); |
| 24 | extern unicode_t apfs_normalize_next(struct apfs_unicursor *cursor, |
| 25 | bool case_fold); |
| 26 | |
| 27 | #endif /* _APFS_UNICODE_H */ |