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 .\" 3. 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: head/lib/libc/stdio/wscanf.3 235363 2012-05-12 20:27:13Z joel $
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
197 or that the conversion will be one of
201 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
211 or that the conversion will be one of
215 and the next pointer is a pointer to a
221 Indicates that the conversion will be one of
225 and the next pointer is a pointer to a
230 Indicates that the conversion will be one of
234 and the next pointer is a pointer to a
239 Indicates that the conversion will be one of
243 and the next pointer is a pointer to a
249 Indicates that the conversion will be one of
253 and the next pointer is a pointer to a
259 In addition to these flags,
260 there may be an optional maximum field width,
261 expressed as a decimal integer,
265 If no width is given,
268 is used (with one exception, below);
269 otherwise at most this many characters are scanned
270 in processing the conversion.
271 Before conversion begins,
272 most conversions skip white space;
273 this white space is not counted against the field width.
275 The following conversions are available:
283 matches a single input
286 No conversion is done, and assignment does not occur.
288 Matches an optionally signed decimal integer;
289 the next pointer must be a pointer to
292 Matches an optionally signed integer;
293 the next pointer must be a pointer to
295 The integer is read in base 16 if it begins
300 in base 8 if it begins with
302 and in base 10 otherwise.
303 Only characters that correspond to the base are used.
305 Matches an octal integer;
306 the next pointer must be a pointer to
309 Matches an optionally signed decimal integer;
310 the next pointer must be a pointer to
313 Matches an optionally signed hexadecimal integer;
314 the next pointer must be a pointer to
316 .It Cm a , A , e , E , f , F , g , G
317 Matches a floating-point number in the style of
319 The next pointer must be a pointer to
328 Matches a sequence of non-white-space wide characters;
329 the next pointer must be a pointer to
331 and the array must be large enough to accept the multibyte representation
332 of all the sequence and the
336 The input string stops at white space
337 or at the maximum field width, whichever occurs first.
341 qualifier is present, the next pointer must be a pointer to
343 into which the input will be placed.
348 Matches a sequence of
351 wide characters (default 1);
352 the next pointer must be a pointer to
354 and there must be enough room for the multibyte representation
355 of all the characters
359 The usual skip of leading white space is suppressed.
360 To skip white space first, use an explicit space in the format.
364 qualifier is present, the next pointer must be a pointer to
366 into which the input will be placed.
371 Matches a nonempty sequence of characters from the specified set
372 of accepted characters;
373 the next pointer must be a pointer to
375 and there must be enough room for the multibyte representation of
376 all the characters in the string,
380 The usual skip of leading white space is suppressed.
381 The string is to be made up of characters in
384 the set is defined by the characters between the open bracket
393 if the first character after the open bracket is a circumflex
395 To include a close bracket in the set,
396 make it the first character after the open bracket
398 any other position will end the set.
399 To include a hyphen in the set,
400 make it the last character before the final close bracket;
401 some implementations of
405 to represent the range of characters between
409 The string ends with the appearance of a character not in the
410 (or, with a circumflex, in) set
411 or when the field width runs out.
415 qualifier is present, the next pointer must be a pointer to
417 into which the input will be placed.
419 Matches a pointer value (as printed by
423 the next pointer must be a pointer to
427 instead, the number of characters consumed thus far from the input
428 is stored through the next pointer,
429 which must be a pointer to
433 a conversion, although it can be suppressed with the
439 character is defined in the program's locale (category
442 For backwards compatibility, a
446 causes an immediate return of
452 the number of input items assigned, which can be fewer than provided
453 for, or even zero, in the event of a matching failure.
455 indicates that, while there was input available,
456 no conversions were assigned;
457 typically this is due to an invalid input character,
458 such as an alphabetic character for a
463 is returned if an input failure occurs before any conversion such as an
465 If an error or end-of-file occurs after conversion
467 the number of conversions which were successfully completed is returned.
491 treats the length modifiers
495 as synonyms, so that the non-standard
505 In addition to the bugs documented in
510 notation for specifying character ranges with the character