As long as I use the
char and not some
wchar_t type to declare a string will
strlen() correctly report the number of
chars in the string or are there some very specific cases I need to be aware of? Here is an example:
char *something = "Report all my chars, please!";
Best How To :
strlen does is basically count all bytes until it hits a zero-byte, the so-called null-terminator, character
So as long as the string contains a terminator within the bounds of the memory allocated for the string,
strlen will correctly return the number of
char in the string.
strlen can't count the number of characters (code points) in a multi-byte encoded string (like UTF-8). It will correctly return the number of bytes in the string though.