 |
Index for Section 3 |
|
 |
Alphabetical listing for P |
|
putwc(3)
NAME
putwc, putwchar, fputwc - Write a wide character to a stream
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <wchar.h>
wint_t putwc(
wint_t wc,
FILE *stream);
wint_t putwchar(
wchar_t wc );
wint_t fputwc(
wint_t wc,
FILE *stream);
For the fputwc() and putwc() functions, application developers may want to
specify an #include statement for <stdio.h> before the one for <wchar.h> if
programs are being developed for multiple platforms. The additional
#include statement is not required on Tru64 UNIX systems or by ISO or
X/Open standards, but may be required on other vendors' systems that
conform to these standards. For the putwchar() function, the XPG4 standard
specifies the parameter type wint_t rather than wchar_t, which is required
by the current version of the ISO C standard. On Tru64 UNIX systems, both
types resolve to int; however, wchar_t and wint_t may not be equivalent
types on other systems that conform to these standards.
STANDARDS
Interfaces documented on this reference page conform to industry standards
as follows:
fputwc(), putwc(), putwchar(): XPG4, XPG4-UNIX
Refer to the standards(5) reference page for more information about
industry standards and associated tags.
PARAMETERS
wc Specifies the wide character to be converted and written.
stream
Points to the output data.
DESCRIPTION
The fputwc() function converts the wchar_t specified by the wc parameter to
its equivalent multibyte character and then writes the multibyte character
to the file or terminal associated with the stream parameter. The function
also advances the file position indicator for stream if the associated file
supports positioning requests. If the file does not support positioning
requests or was opened in append mode, the function appends the character
to the end of stream. The st_ctime and st_mtime fields of the FILE
structure are marked for update between a successful execution of fputwc()
and completion of one of the following:
· A successfully executed call to fflush() or fclose() on the same
stream
· A call to exit() or abort()
If an error occurs while the character is being written, the shift state of
the output file is undefined. See the RESTRICTIONS section for information
about support for shift-state encoding.
The putwc() function performs the same operation as fputwc(), but can be
implemented as a macro on some implementations that conform to X/Open
standards. If implemented as a macro, this function may evaluate stream
more than once; therefore, stream should never be implemented as an
expression with side effects (for example, as in putwc(wc,*f++)).
The putwchar() macro works like the putwc() function, except that
putwchar() writes the character to the standard output stream (stdout). The
call putwchar(wc) is equivalent to putwc(wc, stdout).
[Digital] With the exception of stderr, output streams are, by default,
buffered if they refer to files, or line buffered if they refer to
terminals. The standard error output stream, stderr, is unbuffered by
default, but using the freopen() function causes it to become buffered or
line buffered. Use the setbuf() function to change the stream's buffering
strategy.
RESTRICTIONS
Currently, the Tru64 UNIX product does not include locales whose codesets
use shift-state encoding. Some sections of this reference page refer to
function behavior with respect to shift sequences. This information is
included only for your convenience in developing portable applications that
run on multiple platforms, some of which may supply locales whose codesets
do use shift-state encoding.
RETURN VALUES
On successful completion, these functions return the value written. If
these functions fail, they return the constant WEOF, set the error
indicator for the stream, and set errno to indicate the error.
ERRORS
If any of the following conditions occur, the putwc(), fputwc(), and
putwchar() functions set errno to the corresponding value:
[EAGAIN]
The O_NONBLOCK flag is set for the file descriptor underlying stream
and the process would be delayed in the write operation.
[EBADF]
The file descriptor underlying stream is not a valid file descriptor
open for writing.
[EFBIG]
An attempt was made to write to a file that exceeds the process's
file size limit or the maximum file size.
[EINTR]
The write operation was interrupted by a signal that was caught, and
no data was transferred.
[EILSEQ]
The wide-character code specified by the wc parameter does not
correspond to a valid character in the current locale.
[EIO] One of the following errors occurred:
·
The process is a member of a background process group attempting
to write to its controlling terminal; TOSTOP is set; the process
is neither ignoring nor blocking SIGTTOU; and the process group of
the process is orphaned.
·
[XPG4-UNIX] A physical I/O error occurred.
[ENOSPC]
There was no free space remaining on the device containing the file.
[EPIPE]
An attempt was made to write to a pipe or FIFO that is not open for
reading by any process. A SIGPIPE signal will also be sent to the
process.
RELATED INFORMATION
Functions: getc(3), getwc(3), printf(3), putc(3), puts(3), wctomb(3),
wprintf(3)
Others: i18n_intro(5), l10n_intro(5), standards(5)