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
Post a Comment