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       #include <stdarg.h>
19
20       int vwprintf(const wchar_t *format, va_list args);
21       int vfwprintf(FILE *stream, const wchar_t *format, va_list args);
22       int vswprintf(wchar_t *wcs, size_t maxlen,
23                      const wchar_t *format, va_list args);
24

DESCRIPTION

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

RETURN VALUE

86       The  functions  return the number of wide characters written, excluding
87       the terminating null wide character in case of the functions swprintf()
88       and vswprintf(). They return -1 when an error occurs.
89

CONFORMING TO

91       C99.
92

SEE ALSO

94       fprintf(3), fputwc(3), fwide(3), printf(3), snprintf(3), wscanf(3)
95

NOTES

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