| 1 |
.\" Copyright, Bruno Haible <[email protected]> |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: GPL-2.0-or-later |
| 5 |
.\" |
| 6 |
.TH fwide 3 2026-02-08 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
fwide \- set and determine the orientation of a FILE stream |
| 9 |
.SH LIBRARY |
| 10 |
Standard C library |
| 11 |
.RI ( libc ,\~ \-lc ) |
| 12 |
.SH SYNOPSIS |
| 13 |
.nf |
| 14 |
.B #include <wchar.h> |
| 15 |
.P |
| 16 |
.BI "int fwide(FILE *" stream ", int " mode ); |
| 17 |
.fi |
| 18 |
.P |
| 19 |
.RS -4 |
| 20 |
Feature Test Macro Requirements for glibc (see |
| 21 |
.BR feature_test_macros (7)): |
| 22 |
.RE |
| 23 |
.P |
| 24 |
.BR fwide (): |
| 25 |
.nf |
| 26 |
_XOPEN_SOURCE >= 500 || _ISOC99_SOURCE |
| 27 |
|| _POSIX_C_SOURCE >= 200112L |
| 28 |
.fi |
| 29 |
.SH DESCRIPTION |
| 30 |
When |
| 31 |
.I mode |
| 32 |
is zero, the |
| 33 |
.BR fwide () |
| 34 |
function determines the current |
| 35 |
orientation of |
| 36 |
.IR stream . |
| 37 |
It returns a positive value if |
| 38 |
.I stream |
| 39 |
is wide-character oriented, |
| 40 |
that is, |
| 41 |
if wide-character I/O is permitted but char I/O is disallowed. |
| 42 |
It returns a negative value if |
| 43 |
.I stream |
| 44 |
is byte oriented\[em]that is, |
| 45 |
if char I/O is permitted but wide-character I/O is disallowed. |
| 46 |
It |
| 47 |
returns zero if |
| 48 |
.I stream |
| 49 |
has no orientation yet; |
| 50 |
in this case the next |
| 51 |
I/O operation might change the orientation (to byte oriented if it is a char |
| 52 |
I/O operation, or to wide-character oriented if it is a wide-character I/O |
| 53 |
operation). |
| 54 |
.P |
| 55 |
Once a stream has an orientation, it cannot be changed and persists until |
| 56 |
the stream is closed. |
| 57 |
.P |
| 58 |
When |
| 59 |
.I mode |
| 60 |
is nonzero, the |
| 61 |
.BR fwide () |
| 62 |
function first attempts to set |
| 63 |
.IR stream 's |
| 64 |
orientation (to wide-character oriented |
| 65 |
if |
| 66 |
.I mode |
| 67 |
is greater than 0, |
| 68 |
or to byte oriented if |
| 69 |
.I mode |
| 70 |
is less than 0). |
| 71 |
It then returns a value denoting the |
| 72 |
current orientation, as above. |
| 73 |
.SH RETURN VALUE |
| 74 |
The |
| 75 |
.BR fwide () |
| 76 |
function returns the stream's orientation, after possibly |
| 77 |
changing it. |
| 78 |
A positive return value means wide-character oriented. |
| 79 |
A negative return value means byte oriented. |
| 80 |
A return value of zero means undecided. |
| 81 |
.SH STANDARDS |
| 82 |
C11, POSIX.1-2008. |
| 83 |
.SH HISTORY |
| 84 |
POSIX.1-2001, C99. |
| 85 |
.SH NOTES |
| 86 |
Wide-character output to a byte oriented stream can be performed through the |
| 87 |
.BR fprintf (3) |
| 88 |
function with the |
| 89 |
.B %lc |
| 90 |
and |
| 91 |
.B %ls |
| 92 |
directives. |
| 93 |
.P |
| 94 |
Char oriented output to a wide-character oriented stream can be performed |
| 95 |
through the |
| 96 |
.BR fwprintf (3) |
| 97 |
function with the |
| 98 |
.B %c |
| 99 |
and |
| 100 |
.B %s |
| 101 |
directives. |
| 102 |
.SH SEE ALSO |
| 103 |
.BR fprintf (3), |
| 104 |
.BR fwprintf (3) |