What is the difference between mblen and strlen?
What is the difference between mblen and strlen?
Is today multi-byte character encoding used in Windows, Linux or Mac OS? Is multi-byte character encoding开发者_JAVA技巧 same as fixed-width character encoding in Windows?
strlen
takes the length of a const char *
, and assumes that one char
takes one byte, so it counts the chars until a null terminator ('\0') has been encountered, whereas mblen
takes a pointer also of type const char *
, but this points to the first byte of the multi byte character.
For more info on what are multi-bye characters, have a look at this question.
精彩评论