[Previous] [Contents] [Index] [Next]

mbstrchr()

Search for a multibyte character in a string

Synopsis:

#include <photon/PhProto.h>

char * mbstrchr( char const *string, 
                 char const *mbchar, 
                 int *count );

Description:

The mbstrchr() function searches for a character in string that matches mbchar. If such a match occurs in string, count (if provided) is set to the number of multibyte 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 is returned. If no match is found, the function returns NULL and doesn't change count.

Returns:

A pointer to the matching character, if found, or NULL if not found

Examples:

#include <Pt.h>
main()
  {
  char string[] = "Hello there: äîòéü found"; 
  char mbchar[] = "é";
  int count;
  char *p;

  if( p = mbstrchr( string, mbchar, &count ) )
    printf( 
      "character found: character offset %d\n byte offset %d\n",
      count, p - string );
  else
    printf( " Not found " );
  }

Classification:

Photon

Safety:
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

mbstrnchr(), mbstrrchr()


[Previous] [Contents] [Index] [Next]