From a4c84d2063bb6f2218bc20f89e59001319361f6d Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Sun, 8 Mar 2015 17:23:43 -0400 Subject: fix #2: add charwidth function --- utf8proc.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'utf8proc.h') diff --git a/utf8proc.h b/utf8proc.h index 0d647db..360f919 100644 --- a/utf8proc.h +++ b/utf8proc.h @@ -181,6 +181,7 @@ typedef struct utf8proc_property_struct { unsigned ignorable:1; unsigned control_boundary:1; unsigned boundclass:4; + unsigned charwidth:2; } utf8proc_property_t; #define UTF8PROC_CATEGORY_CN 0 @@ -388,6 +389,21 @@ DLLEXPORT bool utf8proc_grapheme_break(int32_t c1, int32_t c2); * permitted between them (as defined by the extended grapheme clusters in UAX#29). */ +DLLEXPORT int utf8proc_charwidth(int32_t c); +/* Given a codepoint c, return a character width analogous to wcwidth(c), + except that a width of 0 is returned for non-printable characters + instead of -1 as in wcwidth. + + If you want to check for particular types of non-printable characters, + (analogous to isprint or iscntrl), use utf8proc_category(c). */ + +DLLEXPORT int utf8proc_category(int32_t c); +/* Return the Unicode character category for c (one of the + UTF8PROC_CATEGORY_* constants.) */ + +DLLEXPORT const char *utf8proc_category_string(int32_t c); +/* Return the two-letter Unicode category string for c (e.g. "Lu" or "Co"). */ + DLLEXPORT ssize_t utf8proc_map( const uint8_t *str, ssize_t strlen, uint8_t **dstptr, int options ); -- cgit v1.2.3