aboutsummaryrefslogtreecommitdiff
path: root/src/pms_util.h
diff options
context:
space:
mode:
authorMiguel Dalberto Pedro <miguel.pedro@precisioninno.com>2026-10-29 17:55:36 -0300
committerMiguel Dalberto Pedro <miguel.pedro@precisioninno.com>2026-10-29 17:55:36 -0300
commit915478aef931cb57fe56fe568ab4982454a29812 (patch)
tree33057f4773852d99e8cd7ad92d568e79f34847ee /src/pms_util.h
downloadpms-915478aef931cb57fe56fe568ab4982454a29812.tar.gz
pms-915478aef931cb57fe56fe568ab4982454a29812.zip
Initial commit: Padre Matos Soares (1932) Bible corpus and pms CLIHEADmaster
Diffstat (limited to 'src/pms_util.h')
-rw-r--r--src/pms_util.h27
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 */