9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man3c / fwprintf.3c
blob4179c242ce31694498e3d4962649b9a91d023926
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
44 .\" Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
45 .\"
46 .TH FWPRINTF 3C "Nov 1, 2003"
47 .SH NAME
48 fwprintf, wprintf, swprintf \- print formatted wide-character output
49 .SH SYNOPSIS
50 .LP
51 .nf
52 #include <stdio.h>
53 #include <wchar.h>
55 \fBint\fR \fBfwprintf\fR(\fBFILE *restrict\fR \fIstream\fR, \fBconst wchar_t *restrict\fR \fIformat\fR,
56      \fB\fR\fI\&...\fR);
57 .fi
59 .LP
60 .nf
61 \fBint\fR \fBwprintf\fR(\fBconst wchar_t *restrict\fR \fIformat\fR, \fB\fR\fI\&...\fR);
62 .fi
64 .LP
65 .nf
66 \fBint\fR \fBswprintf\fR(\fBwchar_t *restrict\fR \fIs\fR, \fBsize_t\fR \fIn\fR, \fBconst wchar_t *restrict\fR \fIformat\fR,
67      \fB\fR\fI\&...\fR);
68 .fi
70 .SH DESCRIPTION
71 .sp
72 .LP
73 The \fBfwprintf()\fR function places output on the named output \fIstream\fR.
74 The \fBwprintf()\fR function places output on the standard output stream
75 \fBstdout\fR. The \fBswprintf()\fR function places output followed by the null
76 wide-character in consecutive wide-characters starting at \fI*s\fR; no more
77 than \fIn\fR wide-characters are written, including a terminating null
78 wide-character, which is always added (unless \fIn\fR is zero).
79 .sp
80 .LP
81 Each of these functions converts, formats and prints its arguments under
82 control of the \fIformat\fR wide-character string. The \fIformat\fR is composed
83 of zero or more directives: \fBordinary wide-characters\fR, which are simply
84 copied to the output stream and \fBconversion specifications\fR, each of which
85 results in the fetching of zero or more arguments. The results are undefined if
86 there are insufficient arguments for the \fIformat\fR. If the \fIformat\fR is
87 exhausted while arguments remain, the excess arguments are evaluated but are
88 otherwise ignored.
89 .sp
90 .LP
91 Conversions can be applied to the \fIn\fRth argument after the \fIformat\fR in
92 the argument list, rather than to the next unused argument. In this case, the
93 conversion wide-character \fB%\fR (see below) is replaced by the sequence
94 \fB%\fR\fIn\fR\fB$\fR, where \fIn\fR is a decimal integer in the range [1,
95 \fBNL_ARGMAX\fR], giving the position of the argument in the argument list.
96 This feature provides for the definition of format wide-character strings that
97 select arguments in an order appropriate to specific languages (see the
98 \fBEXAMPLES\fR section).
99 .sp
101 In format wide-character strings containing the \fB%\fR\fIn\fR\fB$\fR form of
102 conversion specifications, numbered arguments in the argument list can be
103 referenced from the format wide-character string as many times as required.
106 In format wide-character strings containing the \fB%\fR form of conversion
107 specifications, each argument in the argument list is used exactly once.
110 All forms of the \fBfwprintf()\fR functions allow for the insertion of a
111 language-dependent radix character in the output string, output as a
112 wide-character value. The radix character is defined in the program's locale
113 (category \fBLC_NUMERIC\fR). In the POSIX locale, or in a locale where the
114 radix character is not defined, the radix character defaults to a period
115 (\|.\|).
118 Each conversion specification is introduced by the \fB%\fR wide-character or by
119 the wide-character sequence \fB%\fR\fIn\fR\fB$\fR, after which the following
120 appear in sequence:
121 .RS +4
123 .ie t \(bu
124 .el o
125 Zero or more \fIflags\fR (in any order), which modify the meaning of the
126 conversion specification.
128 .RS +4
130 .ie t \(bu
131 .el o
132 An optional minimum \fIfield width\fR. If the converted value has fewer
133 wide-characters than the field width, it will be padded with spaces by default
134 on the left; it will be padded on the right, if the left-adjustment flag
135 (\fB\(mi\fR), described below, is given to the field width. The field width
136 takes the form of an asterisk (*), described below, or a decimal integer.
138 .RS +4
140 .ie t \(bu
141 .el o
142 An optional \fIprecision\fR that gives the minimum number of digits to appear
143 for the \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, and \fBX\fR conversions;
144 the number of digits to appear after the radix character for the \fBa\fR,
145 \fBA\fR, \fBe\fR, \fBE\fR, \fBf\fR, and \fBF\fR conversions; the maximum number
146 of significant digits for the \fBg\fR and \fBG\fR conversions; or the maximum
147 number of wide-characters to be printed from a string in \fBs\fR conversions.
148 The precision takes the form of a period (.) followed by either an asterisk
149 (*), described below, or an optional decimal digit string, where a null digit
150 string is treated as 0. If a precision appears with any other conversion
151 wide-character, the behavior is undefined.
153 .RS +4
155 .ie t \(bu
156 .el o
157 An optional length modifier that specifies the size of the argument.
159 .RS +4
161 .ie t \(bu
162 .el o
163 A \fIconversion specifier\fR wide character that indicates the type of
164 conversion to be applied.
168 A field width, or precision, or both, may be indicated by an asterisk (*). In
169 this case an argument of type \fBint\fR supplies the field width or precision.
170 Arguments specifying field width, or precision, or both must appear in that
171 order before the argument, if any, to be converted. A negative field width is
172 taken as a \fB\(mi\fR flag followed by a positive field width. A negative
173 precision is taken as if the precision were omitted. In format wide-character
174 strings containing the \fB%\fR\fIn\fR\fB$\fR form of a conversion
175 specification, a field width or precision may be indicated by the sequence
176 \fB*\fR\fIm\fR\fB$\fR, where \fIm\fR is a decimal integer in the range [1,
177 \fBNL_ARGMAX\fR] giving the position in the argument list (after the format
178 argument) of an integer argument containing the field width or precision, for
179 example:
181 .in +2
183 wprintf(L"%1$d:%2$.*3$d:%4$.*3$d\en", hour, min, precision, sec);
185 .in -2
189 The \fIformat\fR can contain either numbered argument specifications (that is,
190 \fB%\fR\fIn\fR\fB$\fR and \fB*\fR\fIm\fR\fB$),\fR or unnumbered argument
191 specifications (that is, \fB%\fR and \fB*\fR), but normally not both. The only
192 exception to this is that \fB%%\fR can be mixed with the \fB%\fR\fIn\fR\fB$\fR
193 form. The results of mixing numbered and unnumbered argument specifications in
194 a \fIformat\fR wide-character string are undefined. When numbered argument
195 specifications are used, specifying the \fIN\fRth argument requires that all
196 the leading arguments, from the first to the (\fIN\(mi1\fR)th, are specified in
197 the format wide-character string.
200 The flag wide-characters and their meanings are:
202 .ne 2
204 \fB\fB\&'\fR\fR
206 .RS 9n
207 The integer portion of the result of a decimal conversion (\fB%i\fR, \fB%d\fR,
208 \fB%u\fR, \fB%f\fR, \fB%F\fR, \fB%g\fR, or \fB%G\fR) will be formatted with
209 thousands' grouping wide-characters. For other conversions the behavior is
210 undefined. The non-monetary grouping wide-character is used.
214 .ne 2
216 \fB\fB\(mi\fR\fR
218 .RS 9n
219 The result of the conversion will be left-justified within the field. The
220 conversion will be right-justified if this flag is not specified.
224 .ne 2
226 \fB\fB+\fR\fR
228 .RS 9n
229 The result of a signed conversion will always begin with a sign (\fB+\fR or
230 \fB\(mi\fR). The conversion will begin with a sign only when a negative value
231 is converted if this flag is not specified.
235 .ne 2
237 \fBspace\fR
239 .RS 9n
240 If the first wide-character of a signed conversion is not a sign or if a signed
241 conversion results in no wide-characters, a space will be prefixed to the
242 result. This means that if the space and \fB+\fR flags both appear, the space
243 flag will be ignored.
247 .ne 2
249 \fB\fB#\fR\fR
251 .RS 9n
252 This flag specifies that the value is to be converted to an alternative form.
253 For \fBo\fR conversion, it increases the precision (if necessary) to force the
254 first digit of the result to be 0. For \fBx\fR or \fBX\fR conversions, a
255 non-zero result will have 0x (or 0X) prefixed to it. For \fBa\fR, \fBA\fR,
256 \fBe\fR, \fBE\fR, \fBf\fR, \fBF\fR, \fBg\fR, or \fBG\fR conversions, the result
257 will always contain a radix character, even if no digits follow it. Without
258 this flag, a radix character appears in the result of these conversions only if
259 a digit follows it. For \fBg\fR and \fBG\fR conversions, trailing zeros will
260 \fInot \fR be removed from the result as they normally are. For other
261 conversions, the behavior is undefined.
265 .ne 2
267 \fB\fB0\fR\fR
269 .RS 9n
270 For \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, \fBX\fR, \fBa\fR, \fBA\fR,
271 \fBe\fR, \fBE\fR, \fBf\fR, \fBF\fR, \fBg\fR, and \fBG\fR conversions, leading
272 zeros (following any indication of sign or base) are used to pad to the field
273 width; no space padding is performed. If the \fB0\fR and \fB\(mi\fR flags both
274 appear, the \fB0\fR flag will be ignored. For \fBd\fR, \fBi\fR, \fBo\fR,
275 \fBu\fR, \fBx\fR, and \fBX\fR conversions, if a precision is specified, the
276 \fB0\fR flag will be ignored. If the \fB0\fR and \fB\&'\fR flags both appear,
277 the grouping wide-characters are inserted before zero padding. For other
278 conversions, the behavior is undefined.
283 The length modifiers and their meanings:
285 .ne 2
287 \fB\fBhh\fR\fR
289 .RS 16n
290 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
291 \fBX\fR conversion specifier applies to a \fBsigned char\fR or \fBunsigned
292 char\fR argument (the argument will have been promoted according to the integer
293 promotions, but its value shall be converted to \fBsigned char\fR or
294 \fBunsigned char\fR before printing); or that a following \fBn\fR conversion
295 specifier applies to a pointer to a \fBsigned char\fR argument.
299 .ne 2
301 \fB\fBh\fR\fR
303 .RS 16n
304 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
305 \fBX\fR conversion specifier applies to a \fBshort\fR or \fBunsigned short\fR
306 argument (the argument will have been promoted according to the integer
307 promotions, but its value shall be converted to \fBshort\fR or \fBunsigned
308 short\fR before printing); or that a following \fBn\fR conversion specifier
309 applies to a pointer to a \fBshort\fR argument.
313 .ne 2
315 \fB\fBl\fR (ell)\fR
317 .RS 16n
318 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
319 \fBX\fR conversion specifier applies to a \fBlong\fR or \fBunsigned long\fR
320 argument; that a following n conversion specifier applies to a pointer to a
321 \fBlong\fR argument; that a following \fBc\fR conversion specifier applies to a
322 \fBwint_t\fR argument; that a following \fBs\fR conversion specifier applies to
323 a pointer to a \fBwchar_t\fR argument; or has no effect on a following \fBa\fR,
324 \fBA\fR, \fBe\fR, \fBE\fR, \fBf\fR, \fBF\fR, \fBg\fR, or \fBG\fR conversion
325 specifier.
329 .ne 2
331 \fB\fBll\fR (ell-ell)\fR
333 .RS 16n
334 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
335 \fBX\fR conversion specifier applies to a\fB long long\fR or unsigned \fBlong
336 long\fR argument; or that a following \fBn\fR conversion specifier applies to a
337 pointer to a \fBlong long\fR argument.
341 .ne 2
343 \fB\fBj\fR\fR
345 .RS 16n
346 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
347 \fBX\fR conversion specifier applies to an \fBintmax_t\fR or \fBuintmax_t\fR
348 argument; or that a following \fBn\fR conversion specifier applies to a pointer
349 to an \fBintmax_t\fR argument.
353 .ne 2
355 \fB\fBz\fR\fR
357 .RS 16n
358 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
359 \fBX\fR conversion specifier applies to a \fBsize_t\fR or the corresponding
360 signed integer type argument; or that a following \fBn\fR conversion specifier
361 applies to a pointer to a signed integer type corresponding to \fBsize_t\fR
362 argument.
366 .ne 2
368 \fB\fBt\fR\fR
370 .RS 16n
371 Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
372 \fBX\fR conversion specifier applies to a \fBptrdiff_t\fR or the corresponding
373 unsigned type argument; or that a following \fBn\fR conversion specifier
374 applies to a pointer to a \fBptrdiff_t\fR argument.
378 .ne 2
380 \fB\fBL\fR\fR
382 .RS 16n
383 Specifies that a following \fBa\fR, \fBA\fR, \fBe\fR, \fBE\fR, \fBf\fR,
384 \fBF\fR, \fBg\fR, or \fBG\fR conversion specifier applies to a long double
385 argument.
390 If a length modifier appears with any conversion specifier other than as
391 specified above, the behavior is undefined.
394 The conversion wide-characters and their meanings are:
396 .ne 2
398 \fB\fBd\fR, \fBi\fR\fR
400 .RS 8n
401 The \fBint\fR argument is converted to a signed decimal in the style
402 \fB[\fR\(mi\fB]\fR\fIdddd\fR. The precision specifies the minimum number of
403 digits to appear; if the value being converted can be represented in fewer
404 digits, it will be expanded with leading zeros. The default precision is 1. The
405 result of converting 0 with an explicit precision of 0 is no wide-characters.
409 .ne 2
411 \fB\fBo\fR\fR
413 .RS 8n
414 The \fBunsigned int\fR argument is converted to unsigned octal format in the
415 style \fIdddd\fR. The precision specifies the minimum number of digits to
416 appear; if the value being converted can be represented in fewer digits, it
417 will be expanded with leading zeros. The default precision is 1. The result of
418 converting 0 with an explicit precision of 0 is no wide-characters.
422 .ne 2
424 \fB\fBu\fR\fR
426 .RS 8n
427 The \fBunsigned int\fR argument is converted to unsigned decimal format in the
428 style \fIdddd\fR. The precision specifies the minimum number of digits to
429 appear; if the value being converted can be represented in fewer digits, it
430 will be expanded with leading zeros. The default precision is 1. The result of
431 converting 0 with an explicit precision of 0 is no wide-characters.
435 .ne 2
437 \fB\fBx\fR\fR
439 .RS 8n
440 The \fBunsigned int\fR argument is converted to unsigned hexadecimal format in
441 the style \fIdddd\fR; the letters abcdef are used. The precision specifies the
442 minimum number of digits to appear; if the value being converted can be
443 represented in fewer digits, it will be expanded with leading zeros. The
444 default precision is 1. The result of converting 0 with an explicit precision
445 of 0 is no wide-characters.
449 .ne 2
451 \fB\fBX\fR\fR
453 .RS 8n
454 Behaves the same as the \fBx\fR conversion wide-character except that letters
455 "\fBABCDEF\fR" are used instead of "\fBabcdef\fR".
459 .ne 2
461 \fB\fBf\fR, \fBF\fR\fR
463 .RS 8n
464 The \fBdouble\fR argument is converted to decimal notation in the style
465 [\fB\(mi\fR]\fIddd\fR\fB\&.\fR\fIddd\fR, where the number of digits after the
466 radix character (see \fBsetlocale\fR(3C)) is equal to the precision
467 specification. If the precision is missing it is taken as 6; if the precision
468 is explicitly 0 and the \fB#\fR flag is not specified, no radix character
469 appears. If a radix character appears, at least 1 digit appears before it. The
470 converted value is rounded to fit the specified output format according to the
471 prevailing floating point rounding direction mode. If the conversion is not
472 exact, an inexact exception is raised.
474 For the \fBf\fR specifier, a double argument representing an infinity or NaN is
475 converted in the style of the \fBe\fR conversion specifier, except that for an
476 infinite argument, "infinity" or "Infinity" is printed when the precision is at
477 least 8 and "inf" or "Inf" is printed otherwise.
479 For the F specifier, a double argument representing an infinity or NaN is
480 converted in the SUSv3 style of the E conversion specifier, except that for an
481 infinite argument, "INFINITY" is printed when the precision is at least 8 and
482 or "INF" is printed otherwise.
486 .ne 2
488 \fB\fBe\fR, \fBE\fR\fR
490 .RS 8n
491 The \fBdouble\fR argument is converted in the style
492 \fB[\fR\(mi\fB]\fR\fId.ddd\fRe\|\(+-\|dd, where there is one digit before the
493 radix character (which is non-zero if the argument is non-zero) and the number
494 of digits after it is equal to the precision; if the precision is missing, it
495 is taken as 6; if the precision is 0 and no \fB#\fR flag is present, no radix
496 character appears. The converted value is rounded to fit the specified output
497 format according to the prevailing floating point rounding direction mode. If
498 the conversion is not exact, an inexact exception is raised. The \fBE\fR
499 conversion wide-character will produce a number with \fBE\fR instead of \fBe\fR
500 introducing the exponent. The exponent always contains at least two digits. If
501 the value is 0, the exponent is 0.
503 Infinity and NaN values are handled in one of the following ways:
505 .ne 2
507 \fBSUSv3\fR
509 .RS 11n
510 For the \fBe\fR specifier, a \fBdouble\fR argument representing an infinity is
511 printed as "[\(mi]\fBinfinity\fR", when the precision for the conversion is at
512 least 7 and as "[\(mi]\fBinf\fR" otherwise. A \fBdouble\fR argument
513 representing a NaN is printed as "[\(mi]\fBnan\fR". For the \fBE\fR specifier,
514 "\fBINF\fR", "\fBINFINITY\fR", and "\fBNAN\fR" are printed instead of
515 "\fBinf\fR", "\fBinfinity\fR", and "\fBnan\fR", respectively. Printing of the
516 sign follows the rules described above.
520 .ne 2
522 \fBDefault\fR
524 .RS 11n
525 A \fBdouble\fR argument representing an infinity is printed as
526 "[\(mi]\fBInfinity\fR", when the precision for the conversion is at least 7 and
527 as "[\(mi]\fBInf\fR" otherwise. A double argument representing a NaN is printed
528 as "[\(mi]\fBNaN\fR". Printing of the sign follows the rules described above.
534 .ne 2
536 \fB\fBg\fR, \fBG\fR\fR
538 .RS 8n
539 The \fBdouble\fR argument is converted in the style \fBf\fR or \fBe\fR (or in
540 the style \fBE\fR in the case of a \fBG\fR conversion wide-character), with the
541 precision specifying the number of significant digits. If an explicit precision
542 is 0, it is taken as 1. The style used depends on the value converted; style
543 \fBe\fR (or \fBE\fR \fB)\fR will be used only if the exponent resulting from
544 such a conversion is less than \(mi4 or greater than or equal to the precision.
545 Trailing zeros are removed from the fractional portion of the result; a radix
546 character appears only if it is followed by a digit.
548 A \fBdouble\fR argument representing an infinity or NaN is converted in the
549 style of the \fBe\fR or \fBE\fR conversion specifier, except that for an
550 infinite argument, "infinity", "INFINITY", or "Infinity" is printed when the
551 precision is at least 8 and "inf", "INF", or "Inf" is printed otherwise.
555 .ne 2
557 \fB\fBa\fR, \fBA\fR\fR
559 .RS 8n
560 A double argument representing a floating-point number is converted in the
561 style "[-]\fB0xh.hhhhp\(+-d\fR", where the single hexadecimal digit preceding
562 the radix point is 0 if the value converted is zero and 1 otherwise and the
563 number of hexadecimal digits after it are equal to the precision; if the
564 precision is missing, the number of digits printed after the radix point is 13
565 for the conversion of a double value, 16 for the conversion of a long double
566 value on x86, and 28 for the conversion of a long double value on SPARC; if the
567 precision is zero and the '#' flag is not specified, no decimal-point wide
568 character appears. The letters "abcdef" are used for \fBa\fR conversion and the
569 letters "ABCDEF" for \fBA\fR conversion. The \fBA\fR conversion specifier
570 produces a number with 'X' and 'P' instead of 'x' and 'p'. The exponent always
571 contains at least one digit, and only as many more digits as necessary to
572 represent the decimal exponent of 2. If the value is zero, the exponent is
573 zero.
575 The converted valueis rounded to fit the specified output format according to
576 the prevailing floating point rounding direction mode. If the conversion is not
577 exact, an inexact exception is raised.
579 A \fBdouble\fR argument representing an infinity or NaN is converted in the
580 SUSv3 style of an \fBe\fR or \fBE\fR conversion specifier.
584 .ne 2
586 \fB\fBc\fR\fR
588 .RS 8n
589 If no \fBl\fR (ell) qualifier is present, the \fBint\fR argument is converted
590 to a wide-character as if by calling the \fBbtowc\fR(3C) function and the
591 resulting wide-character is written. Otherwise the \fBwint_t\fR argument is
592 converted to \fBwchar_t\fR, and written.
596 .ne 2
598 \fB\fBs\fR\fR
600 .RS 8n
601 If no \fBl\fR (ell) qualifier is present, the argument must be a pointer to a
602 character array containing a character sequence beginning in the initial shift
603 state. Characters from the array are converted as if by repeated calls to the
604 \fBmbrtowc\fR(3C) function, with the conversion state described by an
605 \fBmbstate_t\fR object initialized to zero before the first character is
606 converted, and written up to (but not including) the terminating null
607 wide-character. If the precision is specified, no more than that many
608 wide-characters are written. If the precision is not specified or is greater
609 than the size of the array, the array must contain a null wide-character.
611 If an \fBl\fR (ell) qualifier is present, the argument must be a pointer to an
612 array of type \fBwchar_t\fR. Wide characters from the array are written up to
613 (but not including) a terminating null wide-character. If no precision is
614 specified or is greater than the size of the array, the array must contain a
615 null wide-character. If a precision is specified, no more than that many
616 wide-characters are written.
620 .ne 2
622 \fB\fBp\fR\fR
624 .RS 8n
625 The argument must be a pointer to \fBvoid\fR. The value of the pointer is
626 converted to a sequence of printable wide-characters.
630 .ne 2
632 \fB\fBn\fR\fR
634 .RS 8n
635 The argument must be a pointer to an integer into which is written the number
636 of wide-characters written to the output so far by this call to one of the
637 \fBfwprintf()\fR functions. No argument is converted.
641 .ne 2
643 \fB\fBC\fR\fR
645 .RS 8n
646 Same as \fBlc\fR.
650 .ne 2
652 \fB\fBS\fR\fR
654 .RS 8n
655 Same as \fBls\fR.
659 .ne 2
661 \fB\fB%\fR\fR
663 .RS 8n
664 Output a % wide-character; no argument is converted. The entire conversion
665 specification must be \fB%%\fR.
670 If a conversion specification does not match one of the above forms, the
671 behavior is undefined.
674 In no case does a non-existent or small field width cause truncation of a
675 field; if the result of a conversion is wider than the field width, the field
676 is simply expanded to contain the conversion result. Characters generated by
677 \fBfwprintf()\fR and \fBwprintf()\fR are printed as if \fBfputwc\fR(3C) had
678 been called.
681 The \fBst_ctime\fR and \fBst_mtime\fR fields of the file will be marked for
682 update between the call to a successful execution of \fBfwprintf()\fR or
683 \fBwprintf()\fR and the next successful completion of a call to
684 \fBfflush\fR(3C) or \fBfclose\fR(3C) on the same stream or a call to
685 \fBexit\fR(3C) or \fBabort\fR(3C).
686 .SH RETURN VALUES
689 Upon successful completion, these functions return the number of
690 wide-characters transmitted excluding the terminating null wide-character in
691 the case of \fBswprintf()\fR or a negative value if an output error was
692 encountered.
695 If \fIn\fR or more wide characters were requested to be written,
696 \fBswprintf()\fR returns a negative value.
697 .SH ERRORS
700 For the conditions under which \fBfwprintf()\fR and \fBwprintf()\fR will fail
701 and may fail, refer to \fBfputwc\fR(3C).
704 In addition, all forms of \fBfwprintf()\fR may fail if:
706 .ne 2
708 \fB\fBEILSEQ\fR\fR
710 .RS 10n
711 A wide-character code that does not correspond to a valid character has been
712 detected.
716 .ne 2
718 \fB\fBEINVAL\fR\fR
720 .RS 10n
721 There are insufficient arguments.
726 In addition, \fBwprintf()\fR and \fBfwprintf()\fR may fail if:
728 .ne 2
730 \fB\fBENOMEM\fR\fR
732 .RS 10n
733 Insufficient storage space is available.
736 .SH EXAMPLES
738 \fBExample 1 \fRPrint Language-dependent Date and Time Format.
741 To print the language-independent date and time format, the following statement
742 could be used:
745 .in +2
747 wprintf(format, weekday, month, day, hour, min);
749 .in -2
753 For American usage, \fIformat\fR could be a pointer to the wide-character
754 string:
757 .in +2
759 L"%s, %s %d, %d:%.2d\en"
761 .in -2
765 producing the message:
768 .in +2
770 Sunday, July 3, 10:02
772 .in -2
776 whereas for German usage, \fIformat\fR could be a pointer to the wide-character
777 string:
780 .in +2
782 L"%1$s, %3$d. %2$s, %4$d:%5$.2d\en"
784 .in -2
788 producing the message:
791 .in +2
793 Sonntag, 3. Juli, 10:02
795 .in -2
797 .SH ATTRIBUTES
800 See \fBattributes\fR(5) for descriptions of the following attributes:
805 box;
806 c | c
807 l | l .
808 ATTRIBUTE TYPE  ATTRIBUTE VALUE
810 Interface Stability     Standard
812 MT-Level        MT-Safe with exceptions
815 .SH SEE ALSO
818 \fBbtowc\fR(3C), \fBfputwc\fR(3C), \fBfwscanf\fR(3C), \fBmbrtowc\fR(3C),
819 \fBsetlocale\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)
820 .SH NOTES
823 The \fBfwprintf()\fR, \fBwprintf()\fR, and \fBswprintf()\fR functions can be
824 used safely in multithreaded applications, as long as \fBsetlocale\fR(3C) is
825 not being called to change the locale.
828 If the \fBj\fR length modifier is used, 32-bit applications that were compiled
829 using \fBc89\fR on releases prior to Solaris 10 will experience undefined
830 behavior.