How to get the number of visible characters from encoded UTF-8 char *?

I have UTF-8 encoding char*.

Is there a standard function for calculating the number of visible characters represented by an array of bytes?

I'm on Red Hat (RHEL 5).

+3
source share
2 answers

Check out the iconv library: man iconv_open. You can convert the utf-8 string to UCS-2 or UCS-4, where the characters are the same size. iconv is also (relatively) portable, not Linux or GNU specific.

If the Glib suggested earlier is available to you (be careful: this is GPLed), then use it as the best way.

0
source

Yes, glib.h, g_utf8_strlen ()

( )

0

Source: https://habr.com/ru/post/1748918/


All Articles