fwscanf(), swscanf(), wscanf() — Convert formatted wide-character input

Standards

Standards / Extensions C or C++ Dependencies

ISO C Amendment
ISO/ANSI C++
C99
Single UNIX Specification, Version 3
Language Environment

both z/OS® V1R7

Format

Non-XPG4:
#define _MSE_PROTOS
#include <stdio.h>
#include <wchar.h>

int fwscanf(FILE *__restrict__ stream, 
					const wchar_t *__restrict__ format, ... );

int swscanf(const wchar_t * __restrict__ wcs, 
					const wchar_t * __restrict__ format, …);

int wscanf(const wchar_t *__restrict__ format, ... );

#define _OPEN_SYS_UNLOCKED_EXT 1
#include <wchar.h>

int fwscanf_unlocked(FILE *__restrict__ stream, 
					const wchar_t *__restrict__ format, ... );
int wscanf_unlocked(const wchar_t *__restrict__ format, ... );
XPG4 and swscanf():
#define _XOPEN_SOURCE
#define _MSE_PROTOS
#include <wchar.h>

int swscanf(const wchar_t *wcs, const wchar_t *format, …);

General description

The fwscanf(), swscanf(), and wscanf() functions are equivalent to fscanf(), scanf(), and sscanf() respectively, except for the following:

Note: Reaching the end of a wide-character string is equivalent to reaching the end of a char string for the fscanf() and scanf() functions. If copying takes place between objects that overlap, the behavior is undefined.

fwscanf_unlocked() family is functionally equivalent to fwscanf() family with the exception that they are not thread-safe. These functions can safely be used in a multithreaded application if and only if they are called while the invoking thread owns the (FILE*) object, as is the case after a successful call to either the flockfile() or ftrylockfile() function.

Special behavior for XPG4 and swscanf(): If you define any feature test macro specifying XPG4 behavior before the statement in your program source file to include the wchar header, then you must also define the _MSE_PROTOS feature test macro to make the declaration of the swscanf() function in the wchar header available when you compile your program. Please see Table 1 for a list of XPG4 and other feature test macros.

Returned value

If successful, they either return the number of input items assigned, which can be fewer than provided for, or 0 in the event of an early matching failure. If an input failure occurs before any conversion, EOF is returned.

Related information