public asciify
This commit is contained in:
@@ -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 */
|
||||
|
||||
14
lib11sht.h
14
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 */
|
||||
|
||||
Reference in New Issue
Block a user