1 .\" Copyright (c) 1990, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Chris Torek and the American National Standards Committee X3,
6 .\" on Information Processing Systems.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)scanf.3 8.2 (Berkeley) 12/11/93
33 .\" FreeBSD: src/lib/libc/stdio/scanf.3,v 1.24 2003/06/28 09:03:25 das Exp
34 .\" $FreeBSD: src/lib/libc/stdio/wscanf.3,v 1.7 2007/01/09 00:28:08 imp Exp $
46 .Nd wide character input format conversion
53 .Fn wscanf "const wchar_t * restrict format" ...
55 .Fn fwscanf "FILE * restrict stream" "const wchar_t * restrict format" ...
57 .Fn swscanf "const wchar_t * restrict str" "const wchar_t * restrict format" ...
60 .Fn vwscanf "const wchar_t * restrict format" "va_list ap"
62 .Fn vswscanf "const wchar_t * restrict str" "const wchar_t * restrict format" "va_list ap"
64 .Fn vfwscanf "FILE * restrict stream" "const wchar_t * restrict format" "va_list ap"
68 family of functions scans input according to a
71 This format may contain
72 .Em conversion specifiers ;
73 the results from such conversions, if any,
74 are stored through the
80 reads input from the standard input stream
83 reads input from the stream pointer
87 reads its input from the wide character string pointed to by
94 and reads input from the stream pointer
96 using a variable argument list of pointers (see
100 function scans a variable argument list from the standard input and
103 function scans it from a wide character string;
104 these are analogous to
109 functions respectively.
112 argument must correspond properly with
113 each successive conversion specifier
117 All conversions are introduced by the
119 (percent sign) character.
123 may also contain other characters.
124 White space (such as blanks, tabs, or newlines) in the
126 string match any amount of white space, including none, in the input.
130 when an input character does not match such a format character.
132 when an input conversion cannot be made (see below).
136 character introducing a conversion
137 there may be a number of
139 characters, as follows:
140 .Bl -tag -width ".Cm l No (ell)"
142 Suppresses assignment.
143 The conversion that follows occurs as usual, but no pointer is used;
144 the result of the conversion is simply discarded.
146 Indicates that the conversion will be one of
150 and the next pointer is a pointer to a
155 Indicates that the conversion will be one of
159 and the next pointer is a pointer to a
164 Indicates that the conversion will be one of
168 and the next pointer is a pointer to a
172 that the conversion will be one of
176 and the next pointer is a pointer to
180 or that the conversion will be one of
184 and the next pointer is a pointer to an array of
188 .It Cm ll No (ell ell)
189 Indicates that the conversion will be one of
193 and the next pointer is a pointer to a
198 Indicates that the conversion will be one of
202 and the next pointer is a pointer to
205 Indicates that the conversion will be one of
209 and the next pointer is a pointer to a
214 Indicates that the conversion will be one of
218 and the next pointer is a pointer to a
223 Indicates that the conversion will be one of
227 and the next pointer is a pointer to a
233 Indicates that the conversion will be one of
237 and the next pointer is a pointer to a
243 In addition to these flags,
244 there may be an optional maximum field width,
245 expressed as a decimal integer,
249 If no width is given,
252 is used (with one exception, below);
253 otherwise at most this many characters are scanned
254 in processing the conversion.
255 Before conversion begins,
256 most conversions skip white space;
257 this white space is not counted against the field width.
259 The following conversions are available:
267 matches a single input
270 No conversion is done, and assignment does not occur.
272 Matches an optionally signed decimal integer;
273 the next pointer must be a pointer to
276 Matches an optionally signed integer;
277 the next pointer must be a pointer to
279 The integer is read in base 16 if it begins
284 in base 8 if it begins with
286 and in base 10 otherwise.
287 Only characters that correspond to the base are used.
289 Matches an octal integer;
290 the next pointer must be a pointer to
293 Matches an optionally signed decimal integer;
294 the next pointer must be a pointer to
297 Matches an optionally signed hexadecimal integer;
298 the next pointer must be a pointer to
300 .It Cm a , A , e , E , f , F , g , G
301 Matches a floating-point number in the style of
303 The next pointer must be a pointer to
311 Matches a sequence of non-white-space wide characters;
312 the next pointer must be a pointer to
314 and the array must be large enough to accept the multibyte representation
315 of all the sequence and the
319 The input string stops at white space
320 or at the maximum field width, whichever occurs first.
324 qualifier is present, the next pointer must be a pointer to
326 into which the input will be placed.
331 Matches a sequence of
334 wide characters (default 1);
335 the next pointer must be a pointer to
337 and there must be enough room for the multibyte representation
338 of all the characters
342 The usual skip of leading white space is suppressed.
343 To skip white space first, use an explicit space in the format.
347 qualifier is present, the next pointer must be a pointer to
349 into which the input will be placed.
354 Matches a nonempty sequence of characters from the specified set
355 of accepted characters;
356 the next pointer must be a pointer to
358 and there must be enough room for the multibyte representation of
359 all the characters in the string,
363 The usual skip of leading white space is suppressed.
364 The string is to be made up of characters in
367 the set is defined by the characters between the open bracket
376 if the first character after the open bracket is a circumflex
378 To include a close bracket in the set,
379 make it the first character after the open bracket
381 any other position will end the set.
382 To include a hyphen in the set,
383 make it the last character before the final close bracket;
384 some implementations of
388 to represent the range of characters between
392 The string ends with the appearance of a character not in the
393 (or, with a circumflex, in) set
394 or when the field width runs out.
398 qualifier is present, the next pointer must be a pointer to
400 into which the input will be placed.
402 Matches a pointer value (as printed by
406 the next pointer must be a pointer to
410 instead, the number of characters consumed thus far from the input
411 is stored through the next pointer,
412 which must be a pointer to
416 a conversion, although it can be suppressed with the
422 character is defined in the program's locale (category
425 For backwards compatibility, a
429 causes an immediate return of
435 the number of input items assigned, which can be fewer than provided
436 for, or even zero, in the event of a matching failure.
438 indicates that, while there was input available,
439 no conversions were assigned;
440 typically this is due to an invalid input character,
441 such as an alphabetic character for a
446 is returned if an input failure occurs before any conversion such as an
448 If an error or end-of-file occurs after conversion
450 the number of conversions which were successfully completed is returned.
472 In addition to the bugs documented in
477 notation for specifying character ranges with the character