Search for a UTF-8 character in part of a string
#include <utf8.h> char * utf8strnchr( char const *string, char const *mbchar, int num, int *count );
ph
This function searches for a UTF-8 character in string that matches mbchar. The match must occur in the first num UTF-8 characters. If such a match is found, count (if provided) is set to the number of UTF-8 characters the matching character is from the beginning of the string. For example, if mbchar matches the first character in string, count is set to 0. If mbchar matches the second character in string, count is set to 1.
A pointer to the beginning of the matching character within string. If no match is found within num characters, the function returns NULL and doesn't change count.
Search the first 5 UTF-8 characters for a match to the provided UTF-8 character:
#include <Pt.h> int main() { char string[] = "Hello there: äîòéü found"; char mbchar[] = "é"; int count; char *p; if( (p = utf8strchr( string, mbchar, 5, &count ) ) ) printf( "Character found: character offset %d\n byte offset %d.\n", count, p - string ); else printf( "Not found.\" ); return EXIT_SUCCESS; }
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
utf8strchr(), utf8strichr(), utf8strnichr(), utf8strrchr(), utf8strirchr()
Unicode Multilingual Support in the Photon Programmer's Guide