┌──────────────────────────────────────────────────────────────────────┐ │XPG4 provides wide-string handling functions equivalent to those for │ │the multibyte string. The behavior of these functions are affected by │ │the LC_CTYPE category of the current locale. │ └──────────────────────────────────────────────────────────────────────┘
The following table shows the wide string functions.
┌────────────────────┬────────────────────┬─────────────────────────┐ │byte-based │wide-based │Descriptions │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strcat │wcscat │Concatenates two (wide) │ │ │ │strings. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strchr │wcschr │Locates the first │ │ │ │occurrence of a specified│ │ │ │(wide) character in a │ │ │ │(wide) string. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strcmp │wcscmp │Compares the value of two│ │ │ │(wide) strings. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strcoll │wcscoll (**) │Compares two (wide) │ │ │ │strings based on the │ │ │ │collating elements for │ │ │ │the current locale. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strcpy │wcscpy │Copies one (wide) string │ │ │ │to another. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strcspn │wcscspn │Finds the first │ │ │ │occurrence of a (wide) │ │ │ │character in a (wide) │ │ │ │string. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strlen │wcslen │Calculates the length in │ │ │ │byte (wide characters) in│ │ │ │a (wide) string. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strncat │wcsncat │Adds a specified length │ │ │ │in bytes (wide │ │ │ │characters) of one (wide)│ │ │ │string to another. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strncmp │wcsncmp │Compares two (wide) │ │ │ │strings up to a specified│ │ │ │length in bytes (wide │ │ │ │characters). │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strncpy │wcsncpy │Copies a specified length│ │ │ │in bytes (wide │ │ │ │characters) of one (wide)│ │ │ │string to another. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strpbrk │wcspbrk │Locates specified (wide) │ │ │ │characters in a (wide) │ │ │ │string. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strrchr │wcsrchr │Locates the last │ │ │ │occurrence of a (wide) │ │ │ │character in a (wide) │ │ │ │string. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strstr │wcswcs │Locates the first │ │ │ │occurrence of a (wide) │ │ │ │string in another. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strtok │wcstok (**) │Locates a specified token│ │ │ │in a (wide) string. │ ├────────────────────┼────────────────────┼─────────────────────────┤ │strxfrm │wcsxfrm (**) │Transforms (wide) strings│ │ │ │according to the current │ │ │ │locale. │ └────────────────────┴────────────────────┴─────────────────────────┘
The corresponding functions work similar except that:
int strcmp( const char *string1, const char *string2 ); int wcscmp( const wchar_t *string1, const wchar_t *string2 );
const char *string = "ssD1D2ss" const wchar_t *string = L"ssD1D2ss" /* wide string literal */ size_t szLen; szLen = strlen( string ); /* strlen returns 8 = number of bytes */ szLen = wcslen( string ); /* wcslen returns 6 = number of wide characters */
In addition, the following two functions are provided:
┌───────────────┬─────────────────────────────────────────────┐│Function name │Descriptions │ ├───────────────┼─────────────────────────────────────────────┤ │mblen │Determines the length of a multibyte │ │ │character. │ ├───────────────┼─────────────────────────────────────────────┤ │wcswidth │Determin the number of columns in a wide │ │ │string. │ └───────────────┴─────────────────────────────────────────────┘