diff options
author | Steven G. Johnson <stevenj@mit.edu> | 2015-03-08 17:23:43 -0400 |
---|---|---|
committer | Steven G. Johnson <stevenj@mit.edu> | 2015-03-12 12:10:19 -0400 |
commit | a4c84d2063bb6f2218bc20f89e59001319361f6d (patch) | |
tree | bf9799783e0f66c67f0303ea13a778fe51eff539 /utf8proc.c | |
parent | 08f101a9e8c6a72dfdb1c9b913df880e13a36333 (diff) | |
download | libutf8proc-a4c84d2063bb6f2218bc20f89e59001319361f6d.tar.gz libutf8proc-a4c84d2063bb6f2218bc20f89e59001319361f6d.tar.bz2 |
fix #2: add charwidth function
Diffstat (limited to 'utf8proc.c')
-rw-r--r-- | utf8proc.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -223,6 +223,21 @@ DLLEXPORT bool utf8proc_grapheme_break(int32_t c1, int32_t c2) { utf8proc_get_property(c2)->boundclass); } +/* return a character width analogous to wcwidth (except portable and + hopefully less buggy than most system wcwidth functions). */ +DLLEXPORT int utf8proc_charwidth(int32_t c) { + return utf8proc_get_property(c)->charwidth; +} + +DLLEXPORT int utf8proc_category(int32_t c) { + return utf8proc_get_property(c)->category; +} + +DLLEXPORT const char *utf8proc_category_string(int32_t c) { + static const char s[][3] = {"Cn","Lu","Ll","Lt","Lm","Lo","Mn","Mc","Me","Nd","Nl","No","Pc","Pd","Ps","Pe","Pi","Pf","Po","Sm","Sc","Sk","So","Zs","Zl","Zp","Cc","Cf","Cs","Co"}; + return s[utf8proc_category(c)]; +} + #define utf8proc_decompose_lump(replacement_uc) \ return utf8proc_decompose_char((replacement_uc), dst, bufsize, \ options & ~UTF8PROC_LUMP, last_boundclass) |