Debian Codegraph @

upstream/debian-unstable/man3/fgetws.3

raw
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 fgetws 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 fgetws \- read a wide-character string from a FILE stream
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <wchar.h>
16 .P
17 .BR "wchar_t *fgetws(" "int n;"
18 .BI " wchar_t " ws "[restrict " n "], int " n \
19 ", FILE *restrict " stream );
20 .fi
21 .SH DESCRIPTION
22 The
23 .BR fgetws ()
24 function is the wide-character equivalent
25 of the
26 .BR fgets (3)
27 function.
28 It reads a string of at most
29 .I n\-1
30 wide characters into the
31 wide-character array pointed to by
32 .IR ws ,
33 and adds a terminating null wide character (L\[aq]\[rs]0\[aq]).
34 It stops reading wide characters after it has encountered and
35 stored a newline wide character.
36 It also stops when end of stream is reached.
37 .P
38 The programmer must ensure that there is room for at least
39 .I n
40 wide characters at
41 .IR ws .
42 .P
43 For a nonlocking counterpart, see
44 .BR unlocked_stdio (3).
45 .SH RETURN VALUE
46 The
47 .BR fgetws ()
48 function, if successful, returns
49 .IR ws .
50 If end of stream
51 was already reached or if an error occurred, it returns NULL.
52 .SH ATTRIBUTES
53 For an explanation of the terms used in this section, see
54 .BR attributes (7).
55 .TS
56 allbox;
57 lbx lb lb
58 l l l.
59 Interface Attribute Value
60 T{
61 .na
62 .nh
63 .BR fgetws ()
64 T} Thread safety MT-Safe
65 .TE
66 .SH STANDARDS
67 C11, POSIX.1-2008.
68 .SH HISTORY
69 POSIX.1-2001, C99.
70 .SH NOTES
71 The behavior of
72 .BR fgetws ()
73 depends on the
74 .B LC_CTYPE
75 category of the
76 current locale.
77 .P
78 In the absence of additional information passed to the
79 .BR fopen (3)
80 call, it is
81 reasonable to expect that
82 .BR fgetws ()
83 will actually read a multibyte string
84 from the stream and then convert it to a wide-character string.
85 .P
86 This function is unreliable,
87 because it does not permit to deal properly with
88 null wide characters that may be present in the input.
89 .SH SEE ALSO
90 .BR fgetwc (3),
91 .BR unlocked_stdio (3)