| 1 |
'\" t |
| 2 |
.\" Copyright, Bruno Haible <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
.\" |
| 7 |
.TH fgetwc 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
fgetwc, getwc \- read a wide character from a FILE stream |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <stdio.h> |
| 16 |
.B #include <wchar.h> |
| 17 |
.P |
| 18 |
.BI "wint_t fgetwc(FILE *" stream ); |
| 19 |
.BI "wint_t getwc(FILE *" stream ); |
| 20 |
.fi |
| 21 |
.SH DESCRIPTION |
| 22 |
The |
| 23 |
.BR fgetwc () |
| 24 |
function is the wide-character equivalent |
| 25 |
of the |
| 26 |
.BR fgetc (3) |
| 27 |
function. |
| 28 |
It reads a wide character from |
| 29 |
.I stream |
| 30 |
and returns it. |
| 31 |
If the end of stream is reached, or if |
| 32 |
.I ferror(stream) |
| 33 |
becomes true, |
| 34 |
it returns |
| 35 |
.BR WEOF . |
| 36 |
If a wide-character conversion error occurs, it sets |
| 37 |
.I errno |
| 38 |
to |
| 39 |
.B EILSEQ |
| 40 |
and returns |
| 41 |
.BR WEOF . |
| 42 |
.P |
| 43 |
The |
| 44 |
.BR getwc () |
| 45 |
function or macro functions identically to |
| 46 |
.BR fgetwc (). |
| 47 |
It may be implemented as a macro, and may evaluate its argument |
| 48 |
more than once. |
| 49 |
There is no reason ever to use it. |
| 50 |
.P |
| 51 |
For nonlocking counterparts, see |
| 52 |
.BR unlocked_stdio (3). |
| 53 |
.SH RETURN VALUE |
| 54 |
On success, |
| 55 |
.BR fgetwc () |
| 56 |
returns the next wide-character from the stream. |
| 57 |
Otherwise, |
| 58 |
.B WEOF |
| 59 |
is returned, and |
| 60 |
.I errno |
| 61 |
is set to indicate the error. |
| 62 |
.SH ERRORS |
| 63 |
Apart from the usual ones, there is |
| 64 |
.TP |
| 65 |
.B EILSEQ |
| 66 |
The data obtained from the input stream does not |
| 67 |
form a valid character. |
| 68 |
.SH ATTRIBUTES |
| 69 |
For an explanation of the terms used in this section, see |
| 70 |
.BR attributes (7). |
| 71 |
.TS |
| 72 |
allbox; |
| 73 |
lbx lb lb |
| 74 |
l l l. |
| 75 |
Interface Attribute Value |
| 76 |
T{ |
| 77 |
.na |
| 78 |
.nh |
| 79 |
.BR fgetwc (), |
| 80 |
.BR getwc () |
| 81 |
T} Thread safety MT-Safe |
| 82 |
.TE |
| 83 |
.SH STANDARDS |
| 84 |
C11, POSIX.1-2008. |
| 85 |
.SH HISTORY |
| 86 |
POSIX.1-2001, C99. |
| 87 |
.SH NOTES |
| 88 |
The behavior of |
| 89 |
.BR fgetwc () |
| 90 |
depends on the |
| 91 |
.B LC_CTYPE |
| 92 |
category of the |
| 93 |
current locale. |
| 94 |
.P |
| 95 |
In the absence of additional information passed to the |
| 96 |
.BR fopen (3) |
| 97 |
call, it is |
| 98 |
reasonable to expect that |
| 99 |
.BR fgetwc () |
| 100 |
will actually read a multibyte sequence |
| 101 |
from the stream and then convert it to a wide character. |
| 102 |
.SH SEE ALSO |
| 103 |
.BR fgetws (3), |
| 104 |
.BR fputwc (3), |
| 105 |
.BR ungetwc (3), |
| 106 |
.BR unlocked_stdio (3) |