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
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
- mbrlen() — Determine Length of a Multibyte Character (Restartable)
- mbrtowc() — Convert a Multibyte Character to a Wide Character (Restartable)
- mbsrtowcs() — Convert a Multibyte String to a Wide Character String (Restartable)
- setlocale() — Set Locale
- wcrtomb() — Convert a Wide Character to a Multibyte Character (Restartable)
- wcsrtombs() — Convert Wide Character String to Multibyte String (Restartable)
- <locale.h>
- <wchar.h>