c - UTF-8 string size in bytes -


i need determine length of utf-8 string in bytes in c. how correctly? know, in utf-8 terminal symbol has 1-byte size. can use strlen function this?

can use strlen function this?

yes, strlen gives number of bytes before first '\0' character, so

strlen(utf8) + 1 

is number of bytes in utf8 including 0-terminator, since no character other '\0' contains 0 byte in utf-8.

of course, works if utf8 utf-8 encoded, otherwise need convert utf-8 first.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -