The Wide-Character String Functions

The Wide-Character I/O Functions

Several of the I/O functions described in Chapter 6 have wide-character implementations. These functions are shown in the following table. The wide-character I/O functions use the header <wchar.h>. Notice that swprintf( ) and vswprintf( ) require an additional parameter not needed by their char equivalents.

Function

char Equivalent

win_t fgetwc(FILE *stream)

fgetc( )

wchar_t *fgetws(wchar_t *str, int num,
                            FILE *stream)

fgets( )
In C99, str and stream
are qualified by restrict.

wint_t fputwc(wchar_t ch, FILE *stream)

fputc( )

int fputws(const wchar_t *str,
      FILE *stream)

fputs( )
In C99, str and stream
are qualified by restrict.

int fwprintf(FILE *stream,
                    const wchar_t *fmt, ...)

fprintf( )
In C99, str and fmt
are qualified by restrict.

int fwscanf(FILE *stream,
                   const wchar_t *fmt, ...)

fscanf( )
In C99, str and fmt
are qualified by restrict.

wint_t getwc(FILE *stream)

getc( )

wint_t getwchar(void)

getchar( )

wint_t putwc(wchar_t ch, FILE *stream)

putc( )

wint_t putwchar(wchar_t ch)

putchar( )

int swprintf(wchar_t *str, size_t num,
                    const wchar_t *fmt, ...)

sprintf( )
Note the addition of the parameter num, which
limits the number of
characters written to str.
In C99, str and fmt are
qualified by restrict.

int swscanf(const wchar_t *str,
                    const wchar_t *fmt, ...)

sscanf( )
In C99, str and fmt are
qualified by restrict.

wint_t ungetwc(wint_t ch, FILE *stream)

ungetc( )

int vfwprintf(FILE *stream,
                     const wchar_t *fmt, va_list arg)

vfprintf( )
In C99, str and fmt are
qualified by restrict.

int vfwscanf(FILE * restrict stream,
                     const wchar_t * restrict fmt,
                     va_list arg);

vfscanf( ) (Added by C99.)

int vswprintf(wchar_t *str, size_t num,
                      const wchar_t *fmt, va_list arg)

vsprintf( )
Note the addition of the parameter num, which
limits the number of
characters written to str.
In C99, str and fmt are
qualified by restrict.

int vswscanf(const wchar_t * restrict str,
                      const wchar_t * restrict fmt,
                      va_list arg);

vsscanf( ) (Added by C99.)

int vwprintf(const wchar_t
                    *fmt, va_list arg)

vprintf( )
In C99, str and fmt are
qualified by restrict.

int vwscanf(const wchar_t * restrict fmt,
                    va_list arg);

vscanf( ) (Added by C99.)

int wprintf(const wchar_t *fmt, ...)

printf( )
In C99, fmt is qualified
by restrict.

int wscanf(const wchar_t *fmt, ...)

scanf( )
In C99, fmt is qualified
by restrict.

In addition to those shown in the table, the following wide-character I/O function has been added:

int fwide(FILE *stream, int how);

If how is positive, fwide( ) makes stream a wide-character stream. If how is negative, fwide( ) makes stream into a char stream. If how is zero, stream is unaffected. If the stream has already been oriented to either wide or normal characters, it will not be changed. The function returns positive if the stream uses wide characters, negative if the stream uses chars, and zero if the stream has not yet been oriented. A stream’s orientation is also determined by its first use.




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net