mount_setattr.2: Further tweaks after feedback from Christian Brauner
[man-pages.git] / man3 / fgetws.3
blobcfd78b6bb331914c8763c58282398716016deb44
1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2 .\"
3 .\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\" %%%LICENSE_END
9 .\"
10 .\" References consulted:
11 .\"   GNU glibc-2 source code and manual
12 .\"   Dinkumware C library reference http://www.dinkumware.com/
13 .\"   OpenGroup's Single UNIX specification
14 .\"     http://www.UNIX-systems.org/online.html
15 .\"   ISO/IEC 9899:1999
16 .\"
17 .\" Modified Tue Oct 16 23:18:40 BST 2001 by John Levon <moz@compsoc.man.ac.uk>
18 .TH FGETWS 3  2021-03-22 "GNU" "Linux Programmer's Manual"
19 .SH NAME
20 fgetws \- read a wide-character string from a FILE stream
21 .SH SYNOPSIS
22 .nf
23 .B #include <wchar.h>
24 .PP
25 .BI "wchar_t *fgetws(wchar_t *restrict " ws ", int " n \
26 ", FILE *restrict " stream );
27 .fi
28 .SH DESCRIPTION
29 The
30 .BR fgetws ()
31 function is the wide-character equivalent
32 of the
33 .BR fgets (3)
34 function.
35 It reads a string of at most \fIn\-1\fP wide characters into the
36 wide-character array pointed to by \fIws\fP,
37 and adds a terminating null wide character (L\(aq\e0\(aq).
38 It stops reading wide characters after it has encountered and
39 stored a newline wide character.
40 It also stops when end of stream is reached.
41 .PP
42 The programmer must ensure that there is room for at least \fIn\fP wide
43 characters at \fIws\fP.
44 .PP
45 For a nonlocking counterpart, see
46 .BR unlocked_stdio (3).
47 .SH RETURN VALUE
48 The
49 .BR fgetws ()
50 function, if successful, returns \fIws\fP.
51 If end of stream
52 was already reached or if an error occurred, it returns NULL.
53 .SH ATTRIBUTES
54 For an explanation of the terms used in this section, see
55 .BR attributes (7).
56 .ad l
57 .nh
58 .TS
59 allbox;
60 lbx lb lb
61 l l l.
62 Interface       Attribute       Value
64 .BR fgetws ()
65 T}      Thread safety   MT-Safe
66 .TE
67 .hy
68 .ad
69 .sp 1
70 .SH CONFORMING TO
71 POSIX.1-2001, POSIX.1-2008, C99.
72 .SH NOTES
73 The behavior of
74 .BR fgetws ()
75 depends on the
76 .B LC_CTYPE
77 category of the
78 current locale.
79 .PP
80 In the absence of additional information passed to the
81 .BR fopen (3)
82 call, it is
83 reasonable to expect that
84 .BR fgetws ()
85 will actually read a multibyte string
86 from the stream and then convert it to a wide-character string.
87 .PP
88 This function is unreliable,
89 because it does not permit to deal properly with
90 null wide characters that may be present in the input.
91 .SH SEE ALSO
92 .BR fgetwc (3),
93 .BR unlocked_stdio (3)