mbsinit() — Test State Object for Initial State

Format

#include <wchar.h>
int mbsinit (const mbstate_t *ps);

Language Level: ANSI

Threadsafe: Yes

Locale Sensitive: The behavior of this function might be affected by the LC_CTYPE category of the current locale. This function is not available when LOCALETYPE(*CLD) is specified on the compilation command. For more information, see Understanding CCSIDs and Locales.

Description

If ps is not a null pointer, the mbsinit() function specifies whether the pointed to mbstate_t object describes an initial conversion state.

Return Value

The mbsinit() function returns nonzero if ps is a null pointer or if the pointed to object describes an initial conversion state. Otherwise, it returns zero.

Example that uses mbsinit()

This example checks the conversion state to see if it is the initial state.

#include <stdio.h>
#include <wchar.h>
#include <stdlib.h>
 
main()
{
   char     *string = "ABC";
   mbstate_t state = 0;
   wchar_t   wc;
   int   rc;
 
   rc = mbrtowc(&wc, string, MB_CUR_MAX, &state);
   if (mbsinit(&state))
     printf("In initial conversion state\n");
}

Related Information



[ Top of Page | Previous Page | Next Page | Contents | Index ]