2

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 same as fixed-width character encoding in Windows?

Amir Saniyan
  • 13,014
  • 20
  • 92
  • 137

1 Answers1

3

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.

Community
  • 1
  • 1
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415