fwprintf(3S) DG/UX R4.11MU05 fwprintf(3S)
NAME
fwprintf, wprintf, swprintf - print formatted wide character output
SYNOPSIS
#include <stdio.h>
#include <wchar.h>
int fwprintf(FILE *stream, const wchar_t *format, ...);
int wprintf(const wchar_t *format, ...);
int swprintf(wchar_t (s, size_t n, const wchar_t *format, ...);
DESCRIPTION
fwprintf writes output to the stream pointed to by stream, under
control of the wide string pointed to by format that specifies how
arguments are converted for output. If the arguments for the format
are not sufficient, the behavior is undefined. If the format is
exhausted while the arguments remain, the excess arguments are
evaluated but are otherwise ignored.
wprintf writes output to the stream in the same manner as fwprintf,
with the argument stdout interposed before the arguments to wprintf.
swprintf writes output to the stream in the same manner as fwprintf,
except that the argument s specifies an array of wide characters into
which the generated output is written, rather than converted to
multibyte characters and written to a stream. Also, the detection of
encoding errors may differ. No more than n wide characters are
written, including a terminating null wide character, which is always
added unless n is zero. If copying takes place between objects that
overlap, the behavior is undefined.
All wide characters in the format string are members of the basic
character set.
The format is composed of zero or more directives. Ordinary wide
characters (not %) are converted to multibyte characters and written
to the output stream. Conversion specifications get zero or more
arguments. Each conversion specification is introduced by the wide
character % and followed by:
Zero or more flags in any order which modify the meaning of
the conversion specification.
An optional minimum field width. If the converted value has
fewer wide characters that the field width, it is padded with
spaces on the left or right, if the left adjustment flag has
been given, to the field width. The field width takes the
form of an asterisk *, an optional digit, or a decimal
integer.
An optional precision that gives the minimum number of digits
to appear for the b, B, d, i, o, u, x and X conversions, the
number of digits to appear after the decimal point character
for a, A, e, E, f and F, the maximum number of significant
digits for for g and G conversions, or the maximum number of
wide characters written from a string in s conversion. The
precisions takes the form of a period . followed by either an
asterisk *, a digit, or by an optional decimal integer. If
only the period is specified, the precision is taken as zero.
If a precision appears with any other conversion specifier,
the behavior is undefined.
An optional h specifying that a following b, B, d, i, l, L, o,
u, x and X conversion specifier applies to a short int or
unsigned short int argument.
A wide character that specifies the type of conversion to be
applied.
A field width or a precision may be indicated by an asterisk. An int
argument supplies the field width or precision. The arguments
specifying field width, or precision, or both, appear before the
argument to be converted. A negative field width argument is taken
as a flag followed by a positive field width. A negative precision
argument is taken as if the precision were omitted.
The flag wide characters and their meanings are:
- The result of the conversion is left-justified within the
field.
+ the result of a signed conversion always begins with a plus or
minus sign.
space 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 is prefixed to the result. If the space and + flags
both appear, the space flag is ignored.
# The result is converted to an alternate form. For o
conversion, it increases the precision to force the first digit
of the result to be zero, if necessary. For x and X
conversion, a nonzero result has 0x or 0X prefixed to it. For
e, E, f, g and G conversions, the result always contains a
decimal point wide character even if no digits follow it.
Normally, a decimal point character appears in the result of
these conversions only if a digit follows it. For g and G
conversions, trailing zeros are not removed from the result.
For other conversions, the behavior is undefined.
0 For a, A, b, B, d, i, o, u, x, X e, E, f, F, g and G
conversions, leading zeros are used to pad to the field width.
No space padding is performed. If the 0 and - flags both
appear, the 0 flag is ignored. For b, B, d, i, o, u, x and X
conversions, if a precision is specified, the 0 flag is
ignored. For other conversions, the behavior is undefined.
The following section lists the conversion specifiers and their
meanings:
a,A,d,i
The int argument is converted to a signed decimal in the style
[-]dddd. The precision specifies the minimum number of digits
to appear. If the value being converted can be represented in
fewer digits, it is expanded with leading zeros. The default
precision is 1. The result of converting a zero value with a
precision of zero is no wide characters.
b,B,o,u,x,X
The unsigned int argument is converted to an unsigned binary b
or B, unsigned octal o, unsigned decimal d, or unsigned
hexadecimal notation x or X in the style dddd. The letters
abcdef are used for x conversion and the letters ABCDEF are
used for X conversion. The precision specifies the minimum
number of digits to appear. If the value being converted can
be represented in fewer digits, it is expanded with leading
zeros. The default precision is 1. The result of converting
a zero value with a precision of zero is no wide characters.
f,F The double argument is converted to a decimal notation in the
style
[-]ddd.ddd. The number of digits after the decimal point wide
character is equal to the precision specification. If the
precision is missing, it is taken as 6. If the precision is
zero and the # flag is not specified, no decimal point wide
character appears. If a decimal point wide character appears,
at least one digit appears before it. The value is rounded to
the appropriate number of digits.
e,E The double argument is converted in the style [-]d.ddde+dd.
One digit comes before the decimal point wide character and
the number of digits after the decimal point wide character is
equal to the precision specification. If the precision is
missing, it is taken as 6. If the precision is zero and the #
flag is not specified, no decimal point wide character
appears. The value is rounded to the appropriate number of
digits. The E conversion specifier produces a number with E
instead of e introducing the exponent. The exponent always
contains at least two digits. If the value is zero, the
exponent is zero.
g,G The double argument is converted in the style f or e or in the
style E for G conversions, with the precision specifying the
number of significant digits. If the precision is zero, it is
taken as 1. The style used depends on the value converted.
Style e or E is used only if the exponent resulting from such
a conversion is less that -4 or greater than or equal to the
precision. Trailing zeros are removed from the fractional
portion of the result. A decimal point wide character appears
only if it is followed by a digit.
c The wchar_t argument is converted to a multibyte character and
written.
s The argument is a pointer to the initial element of an array
of wchar_t type. Wide characters from the array are converted
to multibyte characters and written up to but not including a
terminating null wide character. If the precision is
specified, no more than that many wide characters are
converted and written. If the precision is not specified or
is greater than the size of the array, the array must contains
a null wide character.
p The argument is a pointer to void. The value of the pointer
is converted to a sequence of printable wide characters, in an
implementation-defined manner.
n The argument is a pointer to an integer into which is written
the number of wide characters written to the output stream so
far by the call to the function. No argument is converted.
% A % is written. No argument is converted. The complete
conversion specification is %%.
Errors
fwprintf and wprintf return the number of wide characters transmitted
or return a negative value if an error was encountered. swprintf
returns the number of wide characters written in the array, not
counting the terminating null wide character, or returns a negative
value if an error was encountered.
USAGE
To print a date and time in the form ``Sunday, July 3, 10:02,''
followed by five decimal places:
fwprintf(stdout, L"%s, %s %d:%.2d:%.2d 0,
weekday, month, day, hour, min);
fwprintf(stdout, L"pi = %.5f", 4 * atan(1.0));
REFERENCES
printf(3S), scanf(3S), setlocale(3C), stdio(3S), write(2)
Licensed material--property of copyright holder(s)