summaryrefslogtreecommitdiff
path: root/usr/src/man/man3c/fwprintf.3c
blob: 00e5c37efcd5ccc55ecee1cec9b4c21e4e9c8674 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
.\"
.\" 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
.\" http://www.opengroup.org/bookstore/.
.\"
.\" 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 SunOS 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.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" 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.
.\"
.\" 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.
.\"
.\" 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]
.\"
.\"
.\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
.\" Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
.\"
.TH FWPRINTF 3C "Nov 1, 2003"
.SH NAME
fwprintf, wprintf, swprintf \- print formatted wide-character output
.SH SYNOPSIS
.LP
.nf
#include <stdio.h>
#include <wchar.h>

\fBint\fR \fBfwprintf\fR(\fBFILE *restrict\fR \fIstream\fR, \fBconst wchar_t *restrict\fR \fIformat\fR,
     \fB\fR\fI\&...\fR);
.fi

.LP
.nf
\fBint\fR \fBwprintf\fR(\fBconst wchar_t *restrict\fR \fIformat\fR, \fB\fR\fI\&...\fR);
.fi

.LP
.nf
\fBint\fR \fBswprintf\fR(\fBwchar_t *restrict\fR \fIs\fR, \fBsize_t\fR \fIn\fR, \fBconst wchar_t *restrict\fR \fIformat\fR,
     \fB\fR\fI\&...\fR);
.fi

.SH DESCRIPTION
.sp
.LP
The \fBfwprintf()\fR function places output on the named output \fIstream\fR.
The \fBwprintf()\fR function places output on the standard output stream
\fBstdout\fR. The \fBswprintf()\fR function places output followed by the null
wide-character in consecutive wide-characters starting at \fI*s\fR; no more
than \fIn\fR wide-characters are written, including a terminating null
wide-character, which is always added (unless \fIn\fR is zero).
.sp
.LP
Each of these functions converts, formats and prints its arguments under
control of the \fIformat\fR wide-character string. The \fIformat\fR is composed
of zero or more directives: \fBordinary wide-characters\fR, which are simply
copied to the output stream and \fBconversion specifications\fR, each of which
results in the fetching of zero or more arguments. The results are undefined if
there are insufficient arguments for the \fIformat\fR. If the \fIformat\fR is
exhausted while arguments remain, the excess arguments are evaluated but are
otherwise ignored.
.sp
.LP
Conversions can be applied to the \fIn\fRth argument after the \fIformat\fR in
the argument list, rather than to the next unused argument. In this case, the
conversion wide-character \fB%\fR (see below) is replaced by the sequence
\fB%\fR\fIn\fR\fB$\fR, where \fIn\fR is a decimal integer in the range [1,
\fBNL_ARGMAX\fR], giving the position of the argument in the argument list.
This feature provides for the definition of format wide-character strings that
select arguments in an order appropriate to specific languages (see the
\fBEXAMPLES\fR section).
.sp
.LP
In format wide-character strings containing the \fB%\fR\fIn\fR\fB$\fR form of
conversion specifications, numbered arguments in the argument list can be
referenced from the format wide-character string as many times as required.
.sp
.LP
In format wide-character strings containing the \fB%\fR form of conversion
specifications, each argument in the argument list is used exactly once.
.sp
.LP
All forms of the \fBfwprintf()\fR functions allow for the insertion of a
language-dependent radix character in the output string, output as a
wide-character value. The radix character is defined in the program's locale
(category \fBLC_NUMERIC\fR). In the POSIX locale, or in a locale where the
radix character is not defined, the radix character defaults to a period
(\|.\|).
.sp
.LP
Each conversion specification is introduced by the \fB%\fR wide-character or by
the wide-character sequence \fB%\fR\fIn\fR\fB$\fR, after which the following
appear in sequence:
.RS +4
.TP
.ie t \(bu
.el o
Zero or more \fIflags\fR (in any order), which modify the meaning of the
conversion specification.
.RE
.RS +4
.TP
.ie t \(bu
.el o
An optional minimum \fIfield width\fR. If the converted value has fewer
wide-characters than the field width, it will be padded with spaces by default
on the left; it will be padded on the right, if the left-adjustment flag
(\fB\(mi\fR), described below, is given to the field width. The field width
takes the form of an asterisk (*), described below, or a decimal integer.
.RE
.RS +4
.TP
.ie t \(bu
.el o
An optional \fIprecision\fR that gives the minimum number of digits to appear
for the \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, and \fBX\fR conversions;
the number of digits to appear after the radix character for the \fBa\fR,
\fBA\fR, \fBe\fR, \fBE\fR, \fBf\fR, and \fBF\fR conversions; the maximum number
of significant digits for the \fBg\fR and \fBG\fR conversions; or the maximum
number of wide-characters to be printed from a string in \fBs\fR conversions.
The precision takes the form of a period (.) followed by either an asterisk
(*), described below, or an optional decimal digit string, where a null digit
string is treated as 0. If a precision appears with any other conversion
wide-character, the behavior is undefined.
.RE
.RS +4
.TP
.ie t \(bu
.el o
An optional length modifier that specifies the size of the argument.
.RE
.RS +4
.TP
.ie t \(bu
.el o
A \fIconversion specifier\fR wide character that indicates the type of
conversion to be applied.
.RE
.sp
.LP
A field width, or precision, or both, may be indicated by an asterisk (*). In
this case an argument of type \fBint\fR supplies the field width or precision.
Arguments specifying field width, or precision, or both must appear in that
order before the argument, if any, to be converted. A negative field width is
taken as a \fB\(mi\fR flag followed by a positive field width. A negative
precision is taken as if the precision were omitted. In format wide-character
strings containing the \fB%\fR\fIn\fR\fB$\fR form of a conversion
specification, a field width or precision may be indicated by the sequence
\fB*\fR\fIm\fR\fB$\fR, where \fIm\fR is a decimal integer in the range [1,
\fBNL_ARGMAX\fR] giving the position in the argument list (after the format
argument) of an integer argument containing the field width or precision, for
example:
.sp
.in +2
.nf
wprintf(L"%1$d:%2$.*3$d:%4$.*3$d\en", hour, min, precision, sec);
.fi
.in -2

.sp
.LP
The \fIformat\fR can contain either numbered argument specifications (that is,
\fB%\fR\fIn\fR\fB$\fR and \fB*\fR\fIm\fR\fB$),\fR or unnumbered argument
specifications (that is, \fB%\fR and \fB*\fR), but normally not both. The only
exception to this is that \fB%%\fR can be mixed with the \fB%\fR\fIn\fR\fB$\fR
form. The results of mixing numbered and unnumbered argument specifications in
a \fIformat\fR wide-character string are undefined. When numbered argument
specifications are used, specifying the \fIN\fRth argument requires that all
the leading arguments, from the first to the (\fIN\(mi1\fR)th, are specified in
the format wide-character string.
.sp
.LP
The flag wide-characters and their meanings are:
.sp
.ne 2
.na
\fB\fB\&'\fR\fR
.ad
.RS 9n
The integer portion of the result of a decimal conversion (\fB%i\fR, \fB%d\fR,
\fB%u\fR, \fB%f\fR, \fB%F\fR, \fB%g\fR, or \fB%G\fR) will be formatted with
thousands' grouping wide-characters. For other conversions the behavior is
undefined. The non-monetary grouping wide-character is used.
.RE

.sp
.ne 2
.na
\fB\fB\(mi\fR\fR
.ad
.RS 9n
The result of the conversion will be left-justified within the field. The
conversion will be right-justified if this flag is not specified.
.RE

.sp
.ne 2
.na
\fB\fB+\fR\fR
.ad
.RS 9n
The result of a signed conversion will always begin with a sign (\fB+\fR or
\fB\(mi\fR). The conversion will begin with a sign only when a negative value
is converted if this flag is not specified.
.RE

.sp
.ne 2
.na
\fBspace\fR
.ad
.RS 9n
If the first wide-character of a signed conversion is not a sign or if a signed
conversion results in no wide-characters, a space will be prefixed to the
result. This means that if the space and \fB+\fR flags both appear, the space
flag will be ignored.
.RE

.sp
.ne 2
.na
\fB\fB#\fR\fR
.ad
.RS 9n
This flag specifies that the value is to be converted to an alternative form.
For \fBo\fR conversion, it increases the precision (if necessary) to force the
first digit of the result to be 0. For \fBx\fR or \fBX\fR conversions, a
non-zero result will have 0x (or 0X) prefixed to it. For \fBa\fR, \fBA\fR,
\fBe\fR, \fBE\fR, \fBf\fR, \fBF\fR, \fBg\fR, or \fBG\fR conversions, the result
will always contain a radix character, even if no digits follow it. Without
this flag, a radix character appears in the result of these conversions only if
a digit follows it. For \fBg\fR and \fBG\fR conversions, trailing zeros will
\fInot \fR be removed from the result as they normally are. For other
conversions, the behavior is undefined.
.RE

.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 9n
For \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, \fBX\fR, \fBa\fR, \fBA\fR,
\fBe\fR, \fBE\fR, \fBf\fR, \fBF\fR, \fBg\fR, and \fBG\fR conversions, leading
zeros (following any indication of sign or base) are used to pad to the field
width; no space padding is performed. If the \fB0\fR and \fB\(mi\fR flags both
appear, the \fB0\fR flag will be ignored. For \fBd\fR, \fBi\fR, \fBo\fR,
\fBu\fR, \fBx\fR, and \fBX\fR conversions, if a precision is specified, the
\fB0\fR flag will be ignored. If the \fB0\fR and \fB\&'\fR flags both appear,
the grouping wide-characters are inserted before zero padding. For other
conversions, the behavior is undefined.
.RE

.sp
.LP
The length modifiers and their meanings:
.sp
.ne 2
.na
\fB\fBhh\fR\fR
.ad
.RS 16n
Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
\fBX\fR conversion specifier applies to a \fBsigned char\fR or \fBunsigned
char\fR argument (the argument will have been promoted according to the integer
promotions, but its value shall be converted to \fBsigned char\fR or
\fBunsigned char\fR before printing); or that a following \fBn\fR conversion
specifier applies to a pointer to a \fBsigned char\fR argument.
.RE

.sp
.ne 2
.na
\fB\fBh\fR\fR
.ad
.RS 16n
Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
\fBX\fR conversion specifier applies to a \fBshort\fR or \fBunsigned short\fR
argument (the argument will have been promoted according to the integer
promotions, but its value shall be converted to \fBshort\fR or \fBunsigned
short\fR before printing); or that a following \fBn\fR conversion specifier
applies to a pointer to a \fBshort\fR argument.
.RE

.sp
.ne 2
.na
\fB\fBl\fR (ell)\fR
.ad
.RS 16n
Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
\fBX\fR conversion specifier applies to a \fBlong\fR or \fBunsigned long\fR
argument; that a following n conversion specifier applies to a pointer to a
\fBlong\fR argument; that a following \fBc\fR conversion specifier applies to a
\fBwint_t\fR argument; that a following \fBs\fR conversion specifier applies to
a pointer to a \fBwchar_t\fR argument; or has no effect on a following \fBa\fR,
\fBA\fR, \fBe\fR, \fBE\fR, \fBf\fR, \fBF\fR, \fBg\fR, or \fBG\fR conversion
specifier.
.RE

.sp
.ne 2
.na
\fB\fBll\fR (ell-ell)\fR
.ad
.RS 16n
Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
\fBX\fR conversion specifier applies to a\fB long long\fR or unsigned \fBlong
long\fR argument; or that a following \fBn\fR conversion specifier applies to a
pointer to a \fBlong long\fR argument.
.RE

.sp
.ne 2
.na
\fB\fBj\fR\fR
.ad
.RS 16n
Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
\fBX\fR conversion specifier applies to an \fBintmax_t\fR or \fBuintmax_t\fR
argument; or that a following \fBn\fR conversion specifier applies to a pointer
to an \fBintmax_t\fR argument.
.RE

.sp
.ne 2
.na
\fB\fBz\fR\fR
.ad
.RS 16n
Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
\fBX\fR conversion specifier applies to a \fBsize_t\fR or the corresponding
signed integer type argument; or that a following \fBn\fR conversion specifier
applies to a pointer to a signed integer type corresponding to \fBsize_t\fR
argument.
.RE

.sp
.ne 2
.na
\fB\fBt\fR\fR
.ad
.RS 16n
Specifies that a following \fBd\fR, \fBi\fR, \fBo\fR, \fBu\fR, \fBx\fR, or
\fBX\fR conversion specifier applies to a \fBptrdiff_t\fR or the corresponding
unsigned type argument; or that a following \fBn\fR conversion specifier
applies to a pointer to a \fBptrdiff_t\fR argument.
.RE

.sp
.ne 2
.na
\fB\fBL\fR\fR
.ad
.RS 16n
Specifies that a following \fBa\fR, \fBA\fR, \fBe\fR, \fBE\fR, \fBf\fR,
\fBF\fR, \fBg\fR, or \fBG\fR conversion specifier applies to a long double
argument.
.RE

.sp
.LP
If a length modifier appears with any conversion specifier other than as
specified above, the behavior is undefined.
.sp
.LP
The conversion wide-characters and their meanings are:
.sp
.ne 2
.na
\fB\fBd\fR, \fBi\fR\fR
.ad
.RS 8n
The \fBint\fR argument is converted to a signed decimal in the style
\fB[\fR\(mi\fB]\fR\fIdddd\fR. The precision specifies the minimum number of
digits to appear; if the value being converted can be represented in fewer
digits, it will be expanded with leading zeros. The default precision is 1. The
result of converting 0 with an explicit precision of 0 is no wide-characters.
.RE

.sp
.ne 2
.na
\fB\fBo\fR\fR
.ad
.RS 8n
The \fBunsigned int\fR argument is converted to unsigned octal format in the
style \fIdddd\fR. The precision specifies the minimum number of digits to
appear; if the value being converted can be represented in fewer digits, it
will be expanded with leading zeros. The default precision is 1. The result of
converting 0 with an explicit precision of 0 is no wide-characters.
.RE

.sp
.ne 2
.na
\fB\fBu\fR\fR
.ad
.RS 8n
The \fBunsigned int\fR argument is converted to unsigned decimal format in the
style \fIdddd\fR. The precision specifies the minimum number of digits to
appear; if the value being converted can be represented in fewer digits, it
will be expanded with leading zeros. The default precision is 1. The result of
converting 0 with an explicit precision of 0 is no wide-characters.
.RE

.sp
.ne 2
.na
\fB\fBx\fR\fR
.ad
.RS 8n
The \fBunsigned int\fR argument is converted to unsigned hexadecimal format in
the style \fIdddd\fR; the letters abcdef are used. The precision specifies the
minimum number of digits to appear; if the value being converted can be
represented in fewer digits, it will be expanded with leading zeros. The
default precision is 1. The result of converting 0 with an explicit precision
of 0 is no wide-characters.
.RE

.sp
.ne 2
.na
\fB\fBX\fR\fR
.ad
.RS 8n
Behaves the same as the \fBx\fR conversion wide-character except that letters
"\fBABCDEF\fR" are used instead of "\fBabcdef\fR".
.RE

.sp
.ne 2
.na
\fB\fBf\fR, \fBF\fR\fR
.ad
.RS 8n
The \fBdouble\fR argument is converted to decimal notation in the style
[\fB\(mi\fR]\fIddd\fR\fB\&.\fR\fIddd\fR, where the number of digits after the
radix character (see \fBsetlocale\fR(3C)) is equal to the precision
specification. If the precision is missing it is taken as 6; if the precision
is explicitly 0 and the \fB#\fR flag is not specified, no radix character
appears. If a radix character appears, at least 1 digit appears before it. The
converted value is rounded to fit the specified output format according to the
prevailing floating point rounding direction mode. If the conversion is not
exact, an inexact exception is raised.
.sp
For the \fBf\fR specifier, a double argument representing an infinity or NaN is
converted in the style of the \fBe\fR conversion specifier, except that for an
infinite argument, "infinity" or "Infinity" is printed when the precision is at
least 8 and "inf" or "Inf" is printed otherwise.
.sp
For the F specifier, a double argument representing an infinity or NaN is
converted in the SUSv3 style of the E conversion specifier, except that for an
infinite argument, "INFINITY" is printed when the precision is at least 8 and
or "INF" is printed otherwise.
.RE

.sp
.ne 2
.na
\fB\fBe\fR, \fBE\fR\fR
.ad
.RS 8n
The \fBdouble\fR argument is converted in the style
\fB[\fR\(mi\fB]\fR\fId.ddd\fRe\|\(+-\|dd, where there is one digit before the
radix character (which is non-zero if the argument is non-zero) and the number
of digits after it is equal to the precision; if the precision is missing, it
is taken as 6; if the precision is 0 and no \fB#\fR flag is present, no radix
character appears. The converted value is rounded to fit the specified output
format according to the prevailing floating point rounding direction mode. If
the conversion is not exact, an inexact exception is raised. The \fBE\fR
conversion wide-character will produce a number with \fBE\fR instead of \fBe\fR
introducing the exponent. The exponent always contains at least two digits. If
the value is 0, the exponent is 0.
.sp
Infinity and NaN values are handled in one of the following ways:
.sp
.ne 2
.na
\fBSUSv3\fR
.ad
.RS 11n
For the \fBe\fR specifier, a \fBdouble\fR argument representing an infinity is
printed as "[\(mi]\fBinfinity\fR", when the precision for the conversion is at
least 7 and as "[\(mi]\fBinf\fR" otherwise. A \fBdouble\fR argument
representing a NaN is printed as "[\(mi]\fBnan\fR". For the \fBE\fR specifier,
"\fBINF\fR", "\fBINFINITY\fR", and "\fBNAN\fR" are printed instead of
"\fBinf\fR", "\fBinfinity\fR", and "\fBnan\fR", respectively. Printing of the
sign follows the rules described above.
.RE

.sp
.ne 2
.na
\fBDefault\fR
.ad
.RS 11n
A \fBdouble\fR argument representing an infinity is printed as
"[\(mi]\fBInfinity\fR", when the precision for the conversion is at least 7 and
as "[\(mi]\fBInf\fR" otherwise. A double argument representing a NaN is printed
as "[\(mi]\fBNaN\fR". Printing of the sign follows the rules described above.
.RE

.RE

.sp
.ne 2
.na
\fB\fBg\fR, \fBG\fR\fR
.ad
.RS 8n
The \fBdouble\fR argument is converted in the style \fBf\fR or \fBe\fR (or in
the style \fBE\fR in the case of a \fBG\fR conversion wide-character), with the
precision specifying the number of significant digits. If an explicit precision
is 0, it is taken as 1. The style used depends on the value converted; style
\fBe\fR (or \fBE\fR \fB)\fR will be used only if the exponent resulting from
such a conversion is less than \(mi4 or greater than or equal to the precision.
Trailing zeros are removed from the fractional portion of the result; a radix
character appears only if it is followed by a digit.
.sp
A \fBdouble\fR argument representing an infinity or NaN is converted in the
style of the \fBe\fR or \fBE\fR conversion specifier, except that for an
infinite argument, "infinity", "INFINITY", or "Infinity" is printed when the
precision is at least 8 and "inf", "INF", or "Inf" is printed otherwise.
.RE

.sp
.ne 2
.na
\fB\fBa\fR, \fBA\fR\fR
.ad
.RS 8n
A double argument representing a floating-point number is converted in the
style "[-]\fB0xh.hhhhp\(+-d\fR", where the single hexadecimal digit preceding
the radix point is 0 if the value converted is zero and 1 otherwise and the
number of hexadecimal digits after it are equal to the precision; if the
precision is missing, the number of digits printed after the radix point is 13
for the conversion of a double value, 16 for the conversion of a long double
value on x86, and 28 for the conversion of a long double value on SPARC; if the
precision is zero and the '#' flag is not specified, no decimal-point wide
character appears. The letters "abcdef" are used for \fBa\fR conversion and the
letters "ABCDEF" for \fBA\fR conversion. The \fBA\fR conversion specifier
produces a number with 'X' and 'P' instead of 'x' and 'p'. The exponent always
contains at least one digit, and only as many more digits as necessary to
represent the decimal exponent of 2. If the value is zero, the exponent is
zero.
.sp
The converted valueis rounded to fit the specified output format according to
the prevailing floating point rounding direction mode. If the conversion is not
exact, an inexact exception is raised.
.sp
A \fBdouble\fR argument representing an infinity or NaN is converted in the
SUSv3 style of an \fBe\fR or \fBE\fR conversion specifier.
.RE

.sp
.ne 2
.na
\fB\fBc\fR\fR
.ad
.RS 8n
If no \fBl\fR (ell) qualifier is present, the \fBint\fR argument is converted
to a wide-character as if by calling the \fBbtowc\fR(3C) function and the
resulting wide-character is written. Otherwise the \fBwint_t\fR argument is
converted to \fBwchar_t\fR, and written.
.RE

.sp
.ne 2
.na
\fB\fBs\fR\fR
.ad
.RS 8n
If no \fBl\fR (ell) qualifier is present, the argument must be a pointer to a
character array containing a character sequence beginning in the initial shift
state. Characters from the array are converted as if by repeated calls to the
\fBmbrtowc\fR(3C) function, with the conversion state described by an
\fBmbstate_t\fR object initialized to zero before the first character is
converted, and written up to (but not including) the terminating null
wide-character. If the precision is specified, no more than that many
wide-characters are written. If the precision is not specified or is greater
than the size of the array, the array must contain a null wide-character.
.sp
If an \fBl\fR (ell) qualifier is present, the argument must be a pointer to an
array of type \fBwchar_t\fR. Wide characters from the array are written up to
(but not including) a terminating null wide-character. If no precision is
specified or is greater than the size of the array, the array must contain a
null wide-character. If a precision is specified, no more than that many
wide-characters are written.
.RE

.sp
.ne 2
.na
\fB\fBp\fR\fR
.ad
.RS 8n
The argument must be a pointer to \fBvoid\fR. The value of the pointer is
converted to a sequence of printable wide-characters.
.RE

.sp
.ne 2
.na
\fB\fBn\fR\fR
.ad
.RS 8n
The argument must be a pointer to an integer into which is written the number
of wide-characters written to the output so far by this call to one of the
\fBfwprintf()\fR functions. No argument is converted.
.RE

.sp
.ne 2
.na
\fB\fBC\fR\fR
.ad
.RS 8n
Same as \fBlc\fR.
.RE

.sp
.ne 2
.na
\fB\fBS\fR\fR
.ad
.RS 8n
Same as \fBls\fR.
.RE

.sp
.ne 2
.na
\fB\fB%\fR\fR
.ad
.RS 8n
Output a % wide-character; no argument is converted. The entire conversion
specification must be \fB%%\fR.
.RE

.sp
.LP
If a conversion specification does not match one of the above forms, the
behavior is undefined.
.sp
.LP
In no case does a non-existent or small field width cause truncation of a
field; if the result of a conversion is wider than the field width, the field
is simply expanded to contain the conversion result. Characters generated by
\fBfwprintf()\fR and \fBwprintf()\fR are printed as if \fBfputwc\fR(3C) had
been called.
.sp
.LP
The \fBst_ctime\fR and \fBst_mtime\fR fields of the file will be marked for
update between the call to a successful execution of \fBfwprintf()\fR or
\fBwprintf()\fR and the next successful completion of a call to
\fBfflush\fR(3C) or \fBfclose\fR(3C) on the same stream or a call to
\fBexit\fR(3C) or \fBabort\fR(3C).
.SH RETURN VALUES
.sp
.LP
Upon successful completion, these functions return the number of
wide-characters transmitted excluding the terminating null wide-character in
the case of \fBswprintf()\fR or a negative value if an output error was
encountered.
.sp
.LP
If \fIn\fR or more wide characters were requested to be written,
\fBswprintf()\fR returns a negative value.
.SH ERRORS
.sp
.LP
For the conditions under which \fBfwprintf()\fR and \fBwprintf()\fR will fail
and may fail, refer to \fBfputwc\fR(3C).
.sp
.LP
In addition, all forms of \fBfwprintf()\fR may fail if:
.sp
.ne 2
.na
\fB\fBEILSEQ\fR\fR
.ad
.RS 10n
A wide-character code that does not correspond to a valid character has been
detected.
.RE

.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
There are insufficient arguments.
.RE

.sp
.LP
In addition, \fBwprintf()\fR and \fBfwprintf()\fR may fail if:
.sp
.ne 2
.na
\fB\fBENOMEM\fR\fR
.ad
.RS 10n
Insufficient storage space is available.
.RE

.SH EXAMPLES
.LP
\fBExample 1 \fRPrint Language-dependent Date and Time Format.
.sp
.LP
To print the language-independent date and time format, the following statement
could be used:

.sp
.in +2
.nf
wprintf(format, weekday, month, day, hour, min);
.fi
.in -2

.sp
.LP
For American usage, \fIformat\fR could be a pointer to the wide-character
string:

.sp
.in +2
.nf
L"%s, %s %d, %d:%.2d\en"
.fi
.in -2

.sp
.LP
producing the message:

.sp
.in +2
.nf
Sunday, July 3, 10:02
.fi
.in -2

.sp
.LP
whereas for German usage, \fIformat\fR could be a pointer to the wide-character
string:

.sp
.in +2
.nf
L"%1$s, %3$d. %2$s, %4$d:%5$.2d\en"
.fi
.in -2

.sp
.LP
producing the message:

.sp
.in +2
.nf
Sonntag, 3. Juli, 10:02
.fi
.in -2

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Standard
_
MT-Level	MT-Safe with exceptions
.TE

.SH SEE ALSO
.sp
.LP
.BR btowc (3C),
.BR fputwc (3C),
.BR fwscanf (3C),
.BR mbrtowc (3C),
.BR setlocale (3C),
.BR attributes (7),
.BR standards (7)
.SH NOTES
.sp
.LP
The \fBfwprintf()\fR, \fBwprintf()\fR, and \fBswprintf()\fR functions can be
used safely in multithreaded applications, as long as \fBsetlocale\fR(3C) is
not being called to change the locale.
.sp
.LP
If the \fBj\fR length modifier is used, 32-bit applications that were compiled
using \fBc89\fR on releases prior to Solaris 10 will experience undefined
behavior.