408 lines
8.8 KiB
HTML
408 lines
8.8 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of WPRINTF</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>WPRINTF</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
wprintf, fwprintf, swprintf, vwprintf, vfwprintf, vswprintf - formatted
|
|
wide-character output conversion
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/stdio.h">stdio.h</A>></B>
|
|
<B>#include <<A HREF="file:///usr/include/wchar.h">wchar.h</A>></B>
|
|
|
|
<B>int wprintf(const wchar_t *</B><I>format</I><B>, ...);</B>
|
|
<B>int fwprintf(FILE *</B><I>stream</I><B>, const wchar_t *</B><I>format</I><B>, ...);</B>
|
|
<B>int swprintf(wchar_t *</B><I>wcs</I><B>, size_t </B><I>maxlen</I><B>,</B>
|
|
<B> const wchar_t *</B><I>format</I><B>, ...);</B>
|
|
|
|
<B>int vwprintf(const wchar_t *</B><I>format</I><B>, va_list </B><I>args</I><B>);</B>
|
|
<B>int vfwprintf(FILE *</B><I>stream</I><B>, const wchar_t *</B><I>format</I><B>, va_list </B><I>args</I><B>);</B>
|
|
<B>int vswprintf(wchar_t *</B><I>wcs</I><B>, size_t </B><I>maxlen</I><B>,</B>
|
|
<B> const wchar_t *</B><I>format</I><B>, va_list </B><I>args</I><B>);</B>
|
|
</PRE>
|
|
|
|
<P>
|
|
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
|
|
|
|
|
|
<P>
|
|
|
|
|
|
All functions shown above:
|
|
<DL COMPACT><DT id="1"><DD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_XOPEN_SOURCE >= 500 || _ISOC99_SOURCE ||
|
|
<BR>
|
|
|
|
_POSIX_C_SOURCE >= 200112L
|
|
</DL>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The
|
|
<B>wprintf</B>()
|
|
|
|
family of functions is
|
|
the wide-character equivalent of the
|
|
<B><A HREF="/cgi-bin/man/man2html?3+printf">printf</A></B>(3)
|
|
|
|
family of functions.
|
|
It performs formatted output of wide
|
|
characters.
|
|
<P>
|
|
|
|
The
|
|
<B>wprintf</B>()
|
|
|
|
and
|
|
<B>vwprintf</B>()
|
|
|
|
functions
|
|
perform wide-character output to
|
|
<I>stdout</I>.
|
|
|
|
<I>stdout</I>
|
|
|
|
must not be byte oriented; see
|
|
<B><A HREF="/cgi-bin/man/man2html?3+fwide">fwide</A></B>(3)
|
|
|
|
for more information.
|
|
<P>
|
|
|
|
The
|
|
<B>fwprintf</B>()
|
|
|
|
and
|
|
<B>vfwprintf</B>()
|
|
|
|
functions
|
|
perform wide-character output to
|
|
<I>stream</I>.
|
|
|
|
<I>stream</I>
|
|
|
|
must not be byte oriented; see
|
|
<B><A HREF="/cgi-bin/man/man2html?3+fwide">fwide</A></B>(3)
|
|
|
|
for more information.
|
|
<P>
|
|
|
|
The
|
|
<B>swprintf</B>()
|
|
|
|
and
|
|
<B>vswprintf</B>()
|
|
|
|
functions
|
|
perform wide-character output
|
|
to an array of wide characters.
|
|
The programmer must ensure that there is
|
|
room for at least
|
|
<I>maxlen</I>
|
|
|
|
wide
|
|
characters at
|
|
<I>wcs</I>.
|
|
|
|
<P>
|
|
|
|
These functions are like
|
|
the
|
|
<B><A HREF="/cgi-bin/man/man2html?3+printf">printf</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+vprintf">vprintf</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+fprintf">fprintf</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+vfprintf">vfprintf</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sprintf">sprintf</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+vsprintf">vsprintf</A></B>(3)
|
|
|
|
functions except for the
|
|
following differences:
|
|
<DL COMPACT>
|
|
<DT id="2"><B>•</B>
|
|
|
|
<DD>
|
|
The
|
|
<I>format</I>
|
|
|
|
string is a wide-character string.
|
|
<DT id="3"><B>•</B>
|
|
|
|
<DD>
|
|
The output consists of wide characters, not bytes.
|
|
<DT id="4"><B>•</B>
|
|
|
|
<DD>
|
|
<B>swprintf</B>()
|
|
|
|
and
|
|
<B>vswprintf</B>()
|
|
|
|
take a
|
|
<I>maxlen</I>
|
|
|
|
argument,
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sprintf">sprintf</A></B>(3)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+vsprintf">vsprintf</A></B>(3)
|
|
|
|
do not.
|
|
(<B><A HREF="/cgi-bin/man/man2html?3+snprintf">snprintf</A></B>(3)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+vsnprintf">vsnprintf</A></B>(3)
|
|
|
|
take a
|
|
<I>maxlen</I>
|
|
|
|
argument, but these functions do not return -1 upon
|
|
buffer overflow on Linux.)
|
|
</DL>
|
|
<P>
|
|
|
|
The treatment of the conversion characters
|
|
<B>c</B>
|
|
|
|
and
|
|
<B>s</B>
|
|
|
|
is different:
|
|
<DL COMPACT>
|
|
<DT id="5"><B>c</B>
|
|
|
|
<DD>
|
|
If no
|
|
<B>l</B>
|
|
|
|
modifier is present, the
|
|
<I>int</I>
|
|
|
|
argument is converted to a wide character by a call to the
|
|
<B><A HREF="/cgi-bin/man/man2html?3+btowc">btowc</A></B>(3)
|
|
|
|
function, and the resulting wide character is written.
|
|
If an
|
|
<B>l</B>
|
|
|
|
modifier is present, the
|
|
<I>wint_t</I>
|
|
|
|
(wide character) argument is written.
|
|
<DT id="6"><B>s</B>
|
|
|
|
<DD>
|
|
If no
|
|
<B>l</B>
|
|
|
|
modifier is present: the
|
|
<I>const char *</I>
|
|
|
|
argument is expected to be a pointer to an array of character type
|
|
(pointer to a string) containing a multibyte character sequence beginning
|
|
in the initial shift state.
|
|
Characters from the array are converted to
|
|
wide characters (each by a call to the
|
|
<B><A HREF="/cgi-bin/man/man2html?3+mbrtowc">mbrtowc</A></B>(3)
|
|
|
|
function with a conversion state starting in the initial state before
|
|
the first byte).
|
|
The resulting wide characters are written up to
|
|
(but not including) the terminating null wide character (L'\0').
|
|
If a precision is
|
|
specified, no more wide characters than the number specified are written.
|
|
Note that the precision determines the number of
|
|
<I>wide characters</I>
|
|
|
|
written, not the number of
|
|
<I>bytes</I>
|
|
|
|
or
|
|
<I>screen positions</I>.
|
|
|
|
The array must contain a terminating null byte ('\0'),
|
|
unless a precision is given
|
|
and it is so small that the number of converted wide characters reaches it
|
|
before the end of the array is reached.
|
|
If an
|
|
<B>l</B>
|
|
|
|
modifier is present: the
|
|
<I>const wchar_t *</I>
|
|
|
|
argument is expected to be a pointer to an array of wide characters.
|
|
Wide characters from the array are written up to (but not including) a
|
|
terminating null wide character.
|
|
If a precision is specified, no more than
|
|
the number specified are written.
|
|
The array must contain a terminating null
|
|
wide character, unless a precision is given and it is smaller than or equal
|
|
to the number of wide characters in the array.
|
|
</DL>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
The functions return the number of wide characters written, excluding the
|
|
terminating null wide character in
|
|
case of the functions
|
|
<B>swprintf</B>()
|
|
|
|
and
|
|
<B>vswprintf</B>().
|
|
|
|
They return -1 when an error occurs.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ATTRIBUTES</H2>
|
|
|
|
For an explanation of the terms used in this section, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
|
|
|
|
<TABLE BORDER>
|
|
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>wprintf</B>(),
|
|
|
|
<B>fwprintf</B>(),
|
|
|
|
<BR>
|
|
|
|
<B>swprintf</B>(),
|
|
|
|
<B>vwprintf</B>(),
|
|
|
|
<BR>
|
|
|
|
<B>vfwprintf</B>(),
|
|
|
|
<B>vswprintf</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Safe locale<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
POSIX.1-2001, POSIX.1-2008, C99.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
The behavior of
|
|
<B>wprintf</B>()
|
|
|
|
et al. depends
|
|
on the
|
|
<B>LC_CTYPE</B>
|
|
|
|
category of the
|
|
current locale.
|
|
<P>
|
|
|
|
If the
|
|
<I>format</I>
|
|
|
|
string contains non-ASCII wide characters, the program
|
|
will work correctly only if the
|
|
<B>LC_CTYPE</B>
|
|
|
|
category of the current locale at
|
|
run time is the same as the
|
|
<B>LC_CTYPE</B>
|
|
|
|
category of the current locale at
|
|
compile time.
|
|
This is because the
|
|
<I>wchar_t</I>
|
|
|
|
representation is platform- and locale-dependent.
|
|
(The glibc represents
|
|
wide characters using their Unicode (ISO-10646) code point, but other
|
|
platforms don't do this.
|
|
Also, the use of C99 universal character names
|
|
of the form \unnnn does not solve this problem.)
|
|
Therefore, in
|
|
internationalized programs, the
|
|
<I>format</I>
|
|
|
|
string should consist of ASCII
|
|
wide characters only, or should be constructed at run time in an
|
|
internationalized way (e.g., using
|
|
<B><A HREF="/cgi-bin/man/man2html?3+gettext">gettext</A></B>(3)
|
|
|
|
or
|
|
<B><A HREF="/cgi-bin/man/man2html?3+iconv">iconv</A></B>(3),
|
|
|
|
followed by
|
|
<B><A HREF="/cgi-bin/man/man2html?3+mbstowcs">mbstowcs</A></B>(3)).
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+fprintf">fprintf</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+fputwc">fputwc</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+fwide">fwide</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+printf">printf</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+snprintf">snprintf</A></B>(3)
|
|
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="7"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="8"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="9"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="10"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="11"><A HREF="#lbAF">ATTRIBUTES</A><DD>
|
|
<DT id="12"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="13"><A HREF="#lbAH">NOTES</A><DD>
|
|
<DT id="14"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="15"><A HREF="#lbAJ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:00 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|