diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-05-31 19:11:52 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-05-31 19:16:00 +0200 |
commit | c0e510b356643089d132688b58a4e02f28f05677 (patch) | |
tree | ed75a964a2ec9ad4a01ae03f16510eda00ecc2dc /lib/unicode/string | |
parent | 114b88f931c7d99d88ad976f6e7c5bb67f1a830d (diff) |
Add uprop_get_wdth() and ucswdth()
Diffstat (limited to 'lib/unicode/string')
-rw-r--r-- | lib/unicode/string/u8wdth.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/unicode/string/u8wdth.c b/lib/unicode/string/u8wdth.c new file mode 100644 index 0000000..503ff7c --- /dev/null +++ b/lib/unicode/string/u8wdth.c @@ -0,0 +1,18 @@ +#include "mbstring.h" +#include "unicode/prop.h" +#include "unicode/string.h" + +size_t +u8wdth(struct u8view sv) +{ + rune ch; + size_t n = 0; + + while (ucsnext(&ch, &sv) != 0) { + int w = uprop_get_wdth(ch); + if (w > 0) + n += w; + } + + return n; +} |