blob: 03ae8ba13b1de14a492e8350f977396724112d09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#ifndef PMS_UTIL_H
#define PMS_UTIL_H
#include <stddef.h>
/*
* Fold a UTF-8 string to lowercase ASCII (stripping Portuguese diacritics).
* Writes at most dst_size - 1 characters + NUL to dst.
* If byte_map is non-NULL (must have at least dst_size ints), byte_map[i]
* stores the byte offset in `src` corresponding to `dst[i]`, and
* byte_map[folded_len] stores strlen(src).
* Returns the length of the folded string in `dst`.
*/
size_t pms_fold_utf8(const char *src, char *dst, size_t dst_size, int *byte_map);
/*
* Normalize a book name/abbreviation query into lowercase alphanumeric ASCII
* (stripping spaces, dots, hyphens, parentheses, and accents).
*/
size_t pms_normalize_book_key(const char *src, char *dst, size_t dst_size);
/*
* Count display columns (UTF-8 codepoints) in a NUL-terminated string or slice.
*/
size_t pms_utf8_char_len(const char *s, size_t byte_len);
#endif /* PMS_UTIL_H */
|