Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man3c / fwprintf.3c
blob05c19c89c5476b8af4b5e0bb627f74c6544a247a
1 '\" te
2 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved. Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\"  This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH FWPRINTF 3C "Nov 1, 2003"
11 .SH NAME
12 fwprintf, wprintf, swprintf \- print formatted wide-character output
13 .SH SYNOPSIS
14 .LP
15 .nf
16 #include <stdio.h>
17 #include <wchar.h>
19 \fBint\fR \fBfwprintf\fR(\fBFILE *restrict\fR \fIstream\fR, \fBconst wchar_t *restrict\fR \fIformat\fR,
20      \fB\fR\fI\&...\fR);
21 .fi
23 .LP
24 .nf
25 \fBint\fR \fBwprintf\fR(\fBconst wchar_t *restrict\fR \fIformat\fR, \fB\fR\fI\&...\fR);
26 .fi
28 .LP
29 .nf
30 \fBint\fR \fBswprintf\fR(\fBwchar_t *restrict\fR \fIs\fR, \fBsize_t\fR \fIn\fR, \fBconst wchar_t *restrict\fR \fIformat\fR,
31      \fB\fR\fI\&...\fR);
32 .fi
34 .SH DESCRIPTION
35 .sp
36 .LP
37 The \fBfwprintf()\fR function places output on the named output \fIstream\fR.
38 The \fBwprintf()\fR function places output on the standard output stream
39 \fBstdout\fR. The \fBswprintf()\fR function places output followed by the null
40 wide-character in consecutive wide-characters starting at \fI*s\fR; no more
41 than \fIn\fR wide-characters are written, including a terminating null
42 wide-character, which is always added (unless \fIn\fR is zero).
43 .sp
44 .LP
45 Each of these functions converts, formats and prints its arguments under
46 control of the \fIformat\fR wide-character string. The \fIformat\fR is composed
47 of zero or more directives: \fBordinary wide-characters\fR, which are simply
48 copied to the output stream and \fBconversion specifications\fR, each of which
49 results in the fetching of zero or more arguments. The results are undefined if
50 there are insufficient arguments for the \fIformat\fR. If the \fIformat\fR is
51 exhausted while arguments remain, the excess arguments are evaluated but are
52 otherwise ignored.
53 .sp
54 .LP
55 Conversions can be applied to the \fIn\fRth argument after the \fIformat\fR in
56 the argument list, rather than to the next unused argument. In this case, the
57 conversion wide-character \fB%\fR (see below) is replaced by the sequence
58 \fB%\fR\fIn\fR\fB$\fR, where \fIn\fR is a decimal integer in the range [1,
59 \fBNL_ARGMAX\fR], giving the position of the argument in the argument list.
60 This feature provides for the definition of format wide-character strings that
61 select arguments in an order appropriate to specific languages (see the
62 \fBEXAMPLES\fR section).
63 .sp
64 .LP
65 In format wide-character strings containing the \fB%\fR\fIn\fR\fB$\fR form of
66 conversion specifications, numbered arguments in the argument list can be
67 referenced from the format wide-character string as many times as required.
68 .sp
69 .LP
70 In format wide-character strings containing the \fB%\fR form of conversion
71 specifications, each argument in the argument list is used exactly once.
72 .sp
73 .LP
74 All forms of the \fBfwprintf()\fR functions allow for the insertion of a
75 language-dependent radix character in the output string, output as a
76 wide-character value. The radix character is defined in the program's locale
77 (category \fBLC_NUMERIC\fR). In the POSIX locale, or in a locale where the
78 radix character is not defined, the radix character defaults to a period
79 (\|.\|).
80 .sp
81 .LP
82 Each conversion specification is introduced by the \fB%\fR wide-character or by
83 the wide-character sequence \fB%\fR\fIn\fR\fB$\fR, after which the following
84 appear in sequence:
85 .RS +4
86 .TP
87 .ie t \(bu
88 .el o
89 Zero or more \fIflags\fR (in any order), which modify the meaning of the
90 conversion specification.
91 .RE
92 .RS +4
93 .TP
94 .ie t \(bu
95 .el o
96 An optional minimum \fIfield width\fR. If the converted value has fewer
97 wide-characters than the field width, it will be padded with spaces by default
98 on the left; it will be padded on the right, if the left-adjustment flag
99 (\fB\(mi\fR), described below, is given to the field width. The field width
100 takes the form of an asterisk (*), described below, or a decimal integer.
102 .RS +4
104 .ie t \(bu
105 .el o
106 An optional \fIprecision\fR that gives the minimum number of digits to appear
107 for the \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, and \fBX\fR conversions;
108 the number of digits to appear after the radix character for the \fBa\fR,
109 \fBA\fR, \fBe\fR, \fBE\fR, \fBf\fR, and \fBF\fR conversions; the maximum number
110 of significant digits for the \fBg\fR and \fBG\fR conversions; or the maximum
111 number of wide-characters to be printed from a string in \fBs\fR conversions.
112 The precision takes the form of a period (.) followed by either an asterisk
113 (*), described below, or an optional decimal digit string, where a null digit
114 string is treated as 0. If a precision appears with any other conversion
115 wide-character, the behavior is undefined.
117 .RS +4
119 .ie t \(bu
120 .el o
121 An optional length modifier that specifies the size of the argument.
123 .RS +4
125 .ie t \(bu
126 .el o
127 A \fIconversion specifier\fR wide character that indicates the type of
128 conversion to be applied.
132 A field width, or precision, or both, may be indicated by an asterisk (*). In
133 this case an argument of type \fBint\fR supplies the field width or precision.
134 Arguments specifying field width, or precision, or both must appear in that
135 order before the argument, if any, to be converted. A negative field width is
136 taken as a \fB\(mi\fR flag followed by a positive field width. A negative
137 precision is taken as if the precision were omitted. In format wide-character
138 strings containing the \fB%\fR\fIn\fR\fB$\fR form of a conversion
139 specification, a field width or precision may be indicated by the sequence
140 \fB*\fR\fIm\fR\fB$\fR, where \fIm\fR is a decimal integer in the range [1,
141 \fBNL_ARGMAX\fR] giving the position in the argument list (after the format
142 argument) of an integer argument containing the field width or precision, for
143 example:
145 .in +2
147 wprintf(L"%1$d:%2$.*3$d:%4$.*3$d\en", hour, min, precision, sec);
149 .in -2
153 The \fIformat\fR can contain either numbered argument specifications (that is,
154 \fB%\fR\fIn\fR\fB$\fR and \fB*\fR\fIm\fR\fB$),\fR or unnumbered argument
155 specifications (that is, \fB%\fR and \fB*\fR), but normally not both. The only
156 exception to this is that \fB%%\fR can be mixed with the \fB%\fR\fIn\fR\fB$\fR
157 form. The results of mixing numbered and unnumbered argument specifications in
158 a \fIformat\fR wide-character string are undefined. When numbered argument
159 specifications are used, specifying the \fIN\fRth argument requires that all
160 the leading arguments, from the first to the (\fIN\(mi1\fR)th, are specified in
161 the format wide-character string.
164 The flag wide-characters and their meanings are:
166 .ne 2
168 \fB\fB\&'\fR\fR
170 .RS 9n
171 The integer portion of the result of a decimal conversion (\fB%i\fR, \fB%d\fR,
172 \fB%u\fR, \fB%f\fR, \fB%F\fR, \fB%g\fR, or \fB%G\fR) will be formatted with
173 thousands' grouping wide-characters. For other conversions the behavior is
174 undefined. The non-monetary grouping wide-character is used.
178 .ne 2
180 \fB\fB\(mi\fR\fR
182 .RS 9n
183 The result of the conversion will be left-justified within the field. The
184 conversion will be right-justified if this flag is not specified.
188 .ne 2
190 \fB\fB+\fR\fR
192 .RS 9n
193 The result of a signed conversion will always begin with a sign (\fB+\fR or
194 \fB\(mi\fR). The conversion will begin with a sign only when a negative value
195 is converted if this flag is not specified.
199 .ne 2
201 \fBspace\fR
203 .RS 9n
204 If the first wide-character of a signed conversion is not a sign or if a signed
205 conversion results in no wide-characters, a space will be prefixed to the
206 result. This means that if the space and \fB+\fR flags both appear, the space
207 flag will be ignored.
211 .ne 2
213 \fB\fB#\fR\fR
215 .RS 9n
216 This flag specifies that the value is to be converted to an alternative form.
217 For \fBo\fR conversion, it increases the precision (if necessary) to force the
218 first digit of the result to be 0. For \fBx\fR or \fBX\fR conversions, a
219 non-zero result will have 0x (or 0X) prefixed to it. For \fBa\fR, \fBA\fR,
220 \fBe\fR, \fBE\fR, \fBf\fR, \fBF\fR, \fBg\fR, or \fBG\fR conversions, the result
221 will always contain a radix character, even if no digits follow it. Without
222 this flag, a radix character appears in the result of these conversions only if
223 a digit follows it. For \fBg\fR and \fBG\fR conversions, trailing zeros will
224 \fInot \fR be removed from the result as they normally are. For other
225 conversions, the behavior is undefined.
229 .ne 2
231 \fB\fB0\fR\fR
233 .RS 9n
234 For \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, \fBX\fR, \fBa\fR, \fBA\fR,
235 \fBe\fR, \fBE\fR, \fBf\fR, \fBF\fR, \fBg\fR, and \fBG\fR conversions, leading
236 zeros (following any indication of sign or base) are used to pad to the field
237 width; no space padding is performed. If the \fB0\fR and \fB\(mi\fR flags both
238 appear, the \fB0\fR flag will be ignored. For \fBd\fR, \fBi\fR, \fBo\fR,
239 \fBu\fR, \fBx\fR, and \fBX\fR conversions, if a precision is specified, the
240 \fB0\fR flag will be ignored. If the \fB0\fR and \fB\&'\fR flags both appear,
241 the grouping wide-characters are inserted before zero padding. For other
242 conversions, the behavior is undefined.
247 The length modifiers and their meanings:
249 .ne 2
251 \fB\fBhh\fR\fR
253 .RS 16n
254 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
255 \fBX\fR conversion specifier applies to a \fBsigned char\fR or \fBunsigned
256 char\fR argument (the argument will have been promoted according to the integer
257 promotions, but its value shall be converted to \fBsigned char\fR or
258 \fBunsigned char\fR before printing); or that a following \fBn\fR conversion
259 specifier applies to a pointer to a \fBsigned char\fR argument.
263 .ne 2
265 \fB\fBh\fR\fR
267 .RS 16n
268 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
269 \fBX\fR conversion specifier applies to a \fBshort\fR or \fBunsigned short\fR
270 argument (the argument will have been promoted according to the integer
271 promotions, but its value shall be converted to \fBshort\fR or \fBunsigned
272 short\fR before printing); or that a following \fBn\fR conversion specifier
273 applies to a pointer to a \fBshort\fR argument.
277 .ne 2
279 \fB\fBl\fR (ell)\fR
281 .RS 16n
282 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
283 \fBX\fR conversion specifier applies to a \fBlong\fR or \fBunsigned long\fR
284 argument; that a following n conversion specifier applies to a pointer to a
285 \fBlong\fR argument; that a following \fBc\fR conversion specifier applies to a
286 \fBwint_t\fR argument; that a following \fBs\fR conversion specifier applies to
287 a pointer to a \fBwchar_t\fR argument; or has no effect on a following \fBa\fR,
288 \fBA\fR, \fBe\fR, \fBE\fR, \fBf\fR, \fBF\fR, \fBg\fR, or \fBG\fR conversion
289 specifier.
293 .ne 2
295 \fB\fBll\fR (ell-ell)\fR
297 .RS 16n
298 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
299 \fBX\fR conversion specifier applies to a\fB long long\fR or unsigned \fBlong
300 long\fR argument; or that a following \fBn\fR conversion specifier applies to a
301 pointer to a \fBlong long\fR argument.
305 .ne 2
307 \fB\fBj\fR\fR
309 .RS 16n
310 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
311 \fBX\fR conversion specifier applies to an \fBintmax_t\fR or \fBuintmax_t\fR
312 argument; or that a following \fBn\fR conversion specifier applies to a pointer
313 to an \fBintmax_t\fR argument.
317 .ne 2
319 \fB\fBz\fR\fR
321 .RS 16n
322 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
323 \fBX\fR conversion specifier applies to a \fBsize_t\fR or the corresponding
324 signed integer type argument; or that a following \fBn\fR conversion specifier
325 applies to a pointer to a signed integer type corresponding to \fBsize_t\fR
326 argument.
330 .ne 2
332 \fB\fBt\fR\fR
334 .RS 16n
335 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
336 \fBX\fR conversion specifier applies to a \fBptrdiff_t\fR or the corresponding
337 unsigned type argument; or that a following \fBn\fR conversion specifier
338 applies to a pointer to a \fBptrdiff_t\fR argument.
342 .ne 2
344 \fB\fBL\fR\fR
346 .RS 16n
347 Specifies that a following \fBa\fR, \fBA\fR, \fBe\fR, \fBE\fR, \fBf\fR,
348 \fBF\fR, \fBg\fR, or \fBG\fR conversion specifier applies to a long double
349 argument.
354 If a length modifier appears with any conversion specifier other than as
355 specified above, the behavior is undefined.
358 The conversion wide-characters and their meanings are:
360 .ne 2
362 \fB\fBd\fR, \fBi\fR\fR
364 .RS 8n
365 The \fBint\fR argument is converted to a signed decimal in the style
366 \fB[\fR\(mi\fB]\fR\fIdddd\fR. The precision specifies the minimum number of
367 digits to appear; if the value being converted can be represented in fewer
368 digits, it will be expanded with leading zeros. The default precision is 1. The
369 result of converting 0 with an explicit precision of 0 is no wide-characters.
373 .ne 2
375 \fB\fBo\fR\fR
377 .RS 8n
378 The \fBunsigned int\fR argument is converted to unsigned octal format in the
379 style \fIdddd\fR. The precision specifies the minimum number of digits to
380 appear; if the value being converted can be represented in fewer digits, it
381 will be expanded with leading zeros. The default precision is 1. The result of
382 converting 0 with an explicit precision of 0 is no wide-characters.
386 .ne 2
388 \fB\fBu\fR\fR
390 .RS 8n
391 The \fBunsigned int\fR argument is converted to unsigned decimal format in the
392 style \fIdddd\fR. The precision specifies the minimum number of digits to
393 appear; if the value being converted can be represented in fewer digits, it
394 will be expanded with leading zeros. The default precision is 1. The result of
395 converting 0 with an explicit precision of 0 is no wide-characters.
399 .ne 2
401 \fB\fBx\fR\fR
403 .RS 8n
404 The \fBunsigned int\fR argument is converted to unsigned hexadecimal format in
405 the style \fIdddd\fR; the letters abcdef are used. The precision specifies the
406 minimum number of digits to appear; if the value being converted can be
407 represented in fewer digits, it will be expanded with leading zeros. The
408 default precision is 1. The result of converting 0 with an explicit precision
409 of 0 is no wide-characters.
413 .ne 2
415 \fB\fBX\fR\fR
417 .RS 8n
418 Behaves the same as the \fBx\fR conversion wide-character except that letters
419 "\fBABCDEF\fR" are used instead of "\fBabcdef\fR".
423 .ne 2
425 \fB\fBf\fR, \fBF\fR\fR
427 .RS 8n
428 The \fBdouble\fR argument is converted to decimal notation in the style
429 [\fB\(mi\fR]\fIddd\fR\fB\&.\fR\fIddd\fR, where the number of digits after the
430 radix character (see \fBsetlocale\fR(3C)) is equal to the precision
431 specification. If the precision is missing it is taken as 6; if the precision
432 is explicitly 0 and the \fB#\fR flag is not specified, no radix character
433 appears. If a radix character appears, at least 1 digit appears before it. The
434 converted value is rounded to fit the specified output format according to the
435 prevailing floating point rounding direction mode. If the conversion is not
436 exact, an inexact exception is raised.
438 For the \fBf\fR specifier, a double argument representing an infinity or NaN is
439 converted in the style of the \fBe\fR conversion specifier, except that for an
440 infinite argument, "infinity" or "Infinity" is printed when the precision is at
441 least 8 and "inf" or "Inf" is printed otherwise.
443 For the F specifier, a double argument representing an infinity or NaN is
444 converted in the SUSv3 style of the E conversion specifier, except that for an
445 infinite argument, "INFINITY" is printed when the precision is at least 8 and
446 or "INF" is printed otherwise.
450 .ne 2
452 \fB\fBe\fR, \fBE\fR\fR
454 .RS 8n
455 The \fBdouble\fR argument is converted in the style
456 \fB[\fR\(mi\fB]\fR\fId.ddd\fRe\|\(+-\|dd, where there is one digit before the
457 radix character (which is non-zero if the argument is non-zero) and the number
458 of digits after it is equal to the precision; if the precision is missing, it
459 is taken as 6; if the precision is 0 and no \fB#\fR flag is present, no radix
460 character appears. The converted value is rounded to fit the specified output
461 format according to the prevailing floating point rounding direction mode. If
462 the conversion is not exact, an inexact exception is raised. The \fBE\fR
463 conversion wide-character will produce a number with \fBE\fR instead of \fBe\fR
464 introducing the exponent. The exponent always contains at least two digits. If
465 the value is 0, the exponent is 0.
467 Infinity and NaN values are handled in one of the following ways:
469 .ne 2
471 \fBSUSv3\fR
473 .RS 11n
474 For the \fBe\fR specifier, a \fBdouble\fR argument representing an infinity is
475 printed as "[\(mi]\fBinfinity\fR", when the precision for the conversion is at
476 least 7 and as "[\(mi]\fBinf\fR" otherwise. A \fBdouble\fR argument
477 representing a NaN is printed as "[\(mi]\fBnan\fR". For the \fBE\fR specifier,
478 "\fBINF\fR", "\fBINFINITY\fR", and "\fBNAN\fR" are printed instead of
479 "\fBinf\fR", "\fBinfinity\fR", and "\fBnan\fR", respectively. Printing of the
480 sign follows the rules described above.
484 .ne 2
486 \fBDefault\fR
488 .RS 11n
489 A \fBdouble\fR argument representing an infinity is printed as
490 "[\(mi]\fBInfinity\fR", when the precision for the conversion is at least 7 and
491 as "[\(mi]\fBInf\fR" otherwise. A double argument representing a NaN is printed
492 as "[\(mi]\fBNaN\fR". Printing of the sign follows the rules described above.
498 .ne 2
500 \fB\fBg\fR, \fBG\fR\fR
502 .RS 8n
503 The \fBdouble\fR argument is converted in the style \fBf\fR or \fBe\fR (or in
504 the style \fBE\fR in the case of a \fBG\fR conversion wide-character), with the
505 precision specifying the number of significant digits. If an explicit precision
506 is 0, it is taken as 1. The style used depends on the value converted; style
507 \fBe\fR (or \fBE\fR \fB)\fR will be used only if the exponent resulting from
508 such a conversion is less than \(mi4 or greater than or equal to the precision.
509 Trailing zeros are removed from the fractional portion of the result; a radix
510 character appears only if it is followed by a digit.
512 A \fBdouble\fR argument representing an infinity or NaN is converted in the
513 style of the \fBe\fR or \fBE\fR conversion specifier, except that for an
514 infinite argument, "infinity", "INFINITY", or "Infinity" is printed when the
515 precision is at least 8 and "inf", "INF", or "Inf" is printed otherwise.
519 .ne 2
521 \fB\fBa\fR, \fBA\fR\fR
523 .RS 8n
524 A double argument representing a floating-point number is converted in the
525 style "[-]\fB0xh.hhhhp\(+-d\fR", where the single hexadecimal digit preceding
526 the radix point is 0 if the value converted is zero and 1 otherwise and the
527 number of hexadecimal digits after it are equal to the precision; if the
528 precision is missing, the number of digits printed after the radix point is 13
529 for the conversion of a double value, 16 for the conversion of a long double
530 value on x86, and 28 for the conversion of a long double value on SPARC; if the
531 precision is zero and the '#' flag is not specified, no decimal-point wide
532 character appears. The letters "abcdef" are used for \fBa\fR conversion and the
533 letters "ABCDEF" for \fBA\fR conversion. The \fBA\fR conversion specifier
534 produces a number with 'X' and 'P' instead of 'x' and 'p'. The exponent always
535 contains at least one digit, and only as many more digits as necessary to
536 represent the decimal exponent of 2. If the value is zero, the exponent is
537 zero.
539 The converted valueis rounded to fit the specified output format according to
540 the prevailing floating point rounding direction mode. If the conversion is not
541 exact, an inexact exception is raised.
543 A \fBdouble\fR argument representing an infinity or NaN is converted in the
544 SUSv3 style of an \fBe\fR or \fBE\fR conversion specifier.
548 .ne 2
550 \fB\fBc\fR\fR
552 .RS 8n
553 If no \fBl\fR (ell) qualifier is present, the \fBint\fR argument is converted
554 to a wide-character as if by calling the \fBbtowc\fR(3C) function and the
555 resulting wide-character is written. Otherwise the \fBwint_t\fR argument is
556 converted to \fBwchar_t\fR, and written.
560 .ne 2
562 \fB\fBs\fR\fR
564 .RS 8n
565 If no \fBl\fR (ell) qualifier is present, the argument must be a pointer to a
566 character array containing a character sequence beginning in the initial shift
567 state. Characters from the array are converted as if by repeated calls to the
568 \fBmbrtowc\fR(3C) function, with the conversion state described by an
569 \fBmbstate_t\fR object initialized to zero before the first character is
570 converted, and written up to (but not including) the terminating null
571 wide-character. If the precision is specified, no more than that many
572 wide-characters are written. If the precision is not specified or is greater
573 than the size of the array, the array must contain a null wide-character.
575 If an \fBl\fR (ell) qualifier is present, the argument must be a pointer to an
576 array of type \fBwchar_t\fR. Wide characters from the array are written up to
577 (but not including) a terminating null wide-character. If no precision is
578 specified or is greater than the size of the array, the array must contain a
579 null wide-character. If a precision is specified, no more than that many
580 wide-characters are written.
584 .ne 2
586 \fB\fBp\fR\fR
588 .RS 8n
589 The argument must be a pointer to \fBvoid\fR. The value of the pointer is
590 converted to a sequence of printable wide-characters.
594 .ne 2
596 \fB\fBn\fR\fR
598 .RS 8n
599 The argument must be a pointer to an integer into which is written the number
600 of wide-characters written to the output so far by this call to one of the
601 \fBfwprintf()\fR functions. No argument is converted.
605 .ne 2
607 \fB\fBC\fR\fR
609 .RS 8n
610 Same as \fBlc\fR.
614 .ne 2
616 \fB\fBS\fR\fR
618 .RS 8n
619 Same as \fBls\fR.
623 .ne 2
625 \fB\fB%\fR\fR
627 .RS 8n
628 Output a % wide-character; no argument is converted. The entire conversion
629 specification must be \fB%%\fR.
634 If a conversion specification does not match one of the above forms, the
635 behavior is undefined.
638 In no case does a non-existent or small field width cause truncation of a
639 field; if the result of a conversion is wider than the field width, the field
640 is simply expanded to contain the conversion result. Characters generated by
641 \fBfwprintf()\fR and \fBwprintf()\fR are printed as if \fBfputwc\fR(3C) had
642 been called.
645 The \fBst_ctime\fR and \fBst_mtime\fR fields of the file will be marked for
646 update between the call to a successful execution of \fBfwprintf()\fR or
647 \fBwprintf()\fR and the next successful completion of a call to
648 \fBfflush\fR(3C) or \fBfclose\fR(3C) on the same stream or a call to
649 \fBexit\fR(3C) or \fBabort\fR(3C).
650 .SH RETURN VALUES
653 Upon successful completion, these functions return the number of
654 wide-characters transmitted excluding the terminating null wide-character in
655 the case of \fBswprintf()\fR or a negative value if an output error was
656 encountered.
659 If \fIn\fR or more wide characters were requested to be written,
660 \fBswprintf()\fR returns a negative value.
661 .SH ERRORS
664 For the conditions under which \fBfwprintf()\fR and \fBwprintf()\fR will fail
665 and may fail, refer to \fBfputwc\fR(3C).
668 In addition, all forms of \fBfwprintf()\fR may fail if:
670 .ne 2
672 \fB\fBEILSEQ\fR\fR
674 .RS 10n
675 A wide-character code that does not correspond to a valid character has been
676 detected.
680 .ne 2
682 \fB\fBEINVAL\fR\fR
684 .RS 10n
685 There are insufficient arguments.
690 In addition, \fBwprintf()\fR and \fBfwprintf()\fR may fail if:
692 .ne 2
694 \fB\fBENOMEM\fR\fR
696 .RS 10n
697 Insufficient storage space is available.
700 .SH EXAMPLES
702 \fBExample 1 \fRPrint Language-dependent Date and Time Format.
705 To print the language-independent date and time format, the following statement
706 could be used:
709 .in +2
711 wprintf(format, weekday, month, day, hour, min);
713 .in -2
717 For American usage, \fIformat\fR could be a pointer to the wide-character
718 string:
721 .in +2
723 L"%s, %s %d, %d:%.2d\en"
725 .in -2
729 producing the message:
732 .in +2
734 Sunday, July 3, 10:02
736 .in -2
740 whereas for German usage, \fIformat\fR could be a pointer to the wide-character
741 string:
744 .in +2
746 L"%1$s, %3$d. %2$s, %4$d:%5$.2d\en"
748 .in -2
752 producing the message:
755 .in +2
757 Sonntag, 3. Juli, 10:02
759 .in -2
761 .SH ATTRIBUTES
764 See \fBattributes\fR(5) for descriptions of the following attributes:
769 box;
770 c | c
771 l | l .
772 ATTRIBUTE TYPE  ATTRIBUTE VALUE
774 Interface Stability     Standard
776 MT-Level        MT-Safe with exceptions
779 .SH SEE ALSO
782 \fBbtowc\fR(3C), \fBfputwc\fR(3C), \fBfwscanf\fR(3C), \fBmbrtowc\fR(3C),
783 \fBsetlocale\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)
784 .SH NOTES
787 The \fBfwprintf()\fR, \fBwprintf()\fR, and \fBswprintf()\fR functions can be
788 used safely in multithreaded applications, as long as \fBsetlocale\fR(3C) is
789 not being called to change the locale.
792 If the \fBj\fR length modifier is used, 32-bit applications that were compiled
793 using \fBc89\fR on releases prior to Solaris 10 will experience undefined
794 behavior.