1WPRINTF(3)                 Linux Programmer's Manual                WPRINTF(3)
2
3
4

NAME

6       wprintf, fwprintf, swprintf, vwprintf, vfwprintf, vswprintf - formatted
7       wide-character output conversion
8

SYNOPSIS

10       #include <stdio.h>
11       #include <wchar.h>
12
13       int wprintf(const wchar_t *format, ...);
14       int fwprintf(FILE *stream, const wchar_t *format, ...);
15       int swprintf(wchar_t *wcs, size_t maxlen,
16                    const wchar_t *format, ...);
17
18       int vwprintf(const wchar_t *format, va_list args);
19       int vfwprintf(FILE *stream, const wchar_t *format, va_list args);
20       int vswprintf(wchar_t *wcs, size_t maxlen,
21                     const wchar_t *format, va_list args);
22
23   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
24
25       All functions shown above:
26           _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE ||
27           _ISOC95_SOURCE /* Since glibc 2.12 */ ||
28           _POSIX_C_SOURCE >= 200112L;
29           or cc -std=c99
30

DESCRIPTION

32       The wprintf() family of functions is the wide-character  equivalent  of
33       the  printf(3)  family  of  functions.  It performs formatted output of
34       wide characters.
35
36       The wprintf() and vwprintf() functions perform wide-character output to
37       stdout.  stdout must not be byte oriented; see fwide(3) for more infor‐
38       mation.
39
40       The fwprintf() and vfwprintf() functions perform wide-character  output
41       to  stream.   stream  must  not be byte oriented; see fwide(3) for more
42       information.
43
44       The swprintf() and vswprintf() functions perform wide-character  output
45       to  an array of wide characters.  The programmer must ensure that there
46       is room for at least maxlen wide characters at wcs.
47
48       These  functions  are  like  the  printf(3),  vprintf(3),   fprintf(3),
49       vfprintf(3), sprintf(3), vsprintf(3) functions except for the following
50       differences:
51
52       ·      The format string is a wide-character string.
53
54       ·      The output consists of wide characters, not bytes.
55
56       ·      swprintf() and vswprintf() take a  maxlen  argument,  sprintf(3)
57              and  vsprintf(3)  do  not.  (snprintf(3) and vsnprintf(3) take a
58              maxlen argument, but these functions do not return -1 upon  buf‐
59              fer overflow on Linux.)
60
61       The treatment of the conversion characters c and s is different:
62
63       c      If  no l modifier is present, the int argument is converted to a
64              wide character by a call  to  the  btowc(3)  function,  and  the
65              resulting  wide  character  is  written.   If  an  l modifier is
66              present, the wint_t (wide character) argument is written.
67
68       s      If no l  modifier  is  present:  The  const char *  argument  is
69              expected  to be a pointer to an array of character type (pointer
70              to a string) containing a multibyte character sequence beginning
71              in  the initial shift state.  Characters from the array are con‐
72              verted to wide characters (each by  a  call  to  the  mbrtowc(3)
73              function  with  a conversion state starting in the initial state
74              before the first byte).  The resulting wide characters are writ‐
75              ten  up to (but not including) the terminating null wide charac‐
76              ter (L'\0').  If a precision is specified, no more wide  charac‐
77              ters  than the number specified are written.  Note that the pre‐
78              cision determines the number of wide characters written, not the
79              number  of  bytes or screen positions.  The array must contain a
80              terminating null byte ('\0'), unless a precision is given and it
81              is so small that the number of converted wide characters reaches
82              it before the end of the array is reached.  If an l modifier  is
83              present:  The  const wchar_t *  argument  is  expected  to  be a
84              pointer to an array of wide characters.   Wide  characters  from
85              the  array  are  written up to (but not including) a terminating
86              null wide character.  If a precision is specified, no more  than
87              the number specified are written.  The array must contain a ter‐
88              minating null wide character, unless a precision is given and it
89              is smaller than or equal to the number of wide characters in the
90              array.
91

RETURN VALUE

93       The functions return the number of wide characters  written,  excluding
94       the terminating null wide character in case of the functions swprintf()
95       and vswprintf().  They return -1 when an error occurs.
96

CONFORMING TO

98       C99.
99

NOTES

101       The behavior of wprintf() et al. depends on the  LC_CTYPE  category  of
102       the current locale.
103
104       If  the  format  string contains non-ASCII wide characters, the program
105       will work correctly only if the LC_CTYPE category of the current locale
106       at  run time is the same as the LC_CTYPE category of the current locale
107       at compile time.  This is because the wchar_t representation  is  plat‐
108       form-  and  locale-dependent.   (The  glibc  represents wide characters
109       using their Unicode (ISO-10646) code point, but other  platforms  don't
110       do  this.   Also,  the use of C99 universal character names of the form
111       \unnnn does not solve this problem.)  Therefore,  in  internationalized
112       programs,  the  format  string  should consist of ASCII wide characters
113       only, or should be constructed at run time in an internationalized  way
114       (e.g., using gettext(3) or iconv(3), followed by mbstowcs(3)).
115

SEE ALSO

117       fprintf(3), fputwc(3), fwide(3), printf(3), snprintf(3)
118

COLOPHON

120       This  page  is  part of release 3.53 of the Linux man-pages project.  A
121       description of the project, and information about reporting  bugs,  can
122       be found at http://www.kernel.org/doc/man-pages/.
123
124
125
126GNU                               2011-09-17                        WPRINTF(3)
Impressum