I have a UTF-8 encoded char*
.
Is there a standard function to calculate the number of visible characters represented by the byte array?
I'm on Red Hat (RHEL 5).
I have a UTF-8 encoded char*
.
Is there a standard function to calculate the number of visible characters represented by the byte array?
I'm on Red Hat (RHEL 5).
Yes, glib.h
, has g_utf8_strlen()
Check out this page for more information (including three implementations of an algo to do this)
Check the iconv library: man iconv_open. One can convert the utf-8 string into say UCS-2 or UCS-4 where characters are of the same size. iconv is also (relatively) portable and not Linux or GNU specific.
If Glib, suggested before, is available to you (beware: it is GPLed) then use it as it is a better way.