diff --git a/lib11sht.c b/lib11sht.c index d7caadc..c41bf8a 100644 --- a/lib11sht.c +++ b/lib11sht.c @@ -16,8 +16,7 @@ /* Internal helpers -- kept private to this translation unit. */ static int uselesschar(int c); -/* trim is public (declared in lib11sht.h) */ -static void asciify(const char *src, char *dest, size_t dest_size); +/* trim and asciify are public (declared in lib11sht.h) */ static int ulen(unsigned char c); static float shit11(char *s1, char *s2); static float fmin3(float a, float b, float c); @@ -210,7 +209,7 @@ static int ulen(unsigned char c) } /* ---------------------------------------------------------------------- */ -static void asciify(const char *src, char *dest, size_t dest_size) +void asciify(const char *src, char *dest, size_t dest_size) { int len, i, k, j, found; char ch[5]; /* UTF8 multibyte char */ diff --git a/lib11sht.h b/lib11sht.h index 16afe90..1203b6b 100644 --- a/lib11sht.h +++ b/lib11sht.h @@ -92,4 +92,18 @@ int fequal(float a, float b, float delta); * be NUL-terminated. */ void trim(char *s); +/* Transliterate accented Latin chars to plain ASCII. Walks src as UTF-8, + * mapping known accented chars (a-acute, c-cedilla, n-tilde, NBSP, ...) + * to their ASCII equivalents and copying ASCII bytes verbatim. Output is + * always pure ASCII and NUL-terminated. Bytes that don't match the + * transliteration table are skipped. + * + * Parameters: + * src input UTF-8 string (NUL-terminated) + * dest output buffer (filled with NUL-terminated ASCII) + * dest_size size of dest in bytes (writes capped at dest_size-1 + final NUL) + * + * Safe for NULL / zero-size args (no-op). */ +void asciify(const char *src, char *dest, size_t dest_size); + #endif /* LIB11SHT_H */