diff options
| author | Miguel Dalberto Pedro <miguel.pedro@precisioninno.com> | 2026-10-29 17:55:36 -0300 |
|---|---|---|
| committer | Miguel Dalberto Pedro <miguel.pedro@precisioninno.com> | 2026-10-29 17:55:36 -0300 |
| commit | 915478aef931cb57fe56fe568ab4982454a29812 (patch) | |
| tree | 33057f4773852d99e8cd7ad92d568e79f34847ee /src/pms_util.h | |
| download | pms-915478aef931cb57fe56fe568ab4982454a29812.tar.gz pms-915478aef931cb57fe56fe568ab4982454a29812.zip | |
Diffstat (limited to 'src/pms_util.h')
| -rw-r--r-- | src/pms_util.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/pms_util.h b/src/pms_util.h new file mode 100644 index 0000000..03ae8ba --- /dev/null +++ b/src/pms_util.h @@ -0,0 +1,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 */ |
