1 .\" $NetBSD: wscanf.3,v 1.3 2010/12/16 17:42:27 wiz Exp $
2 .\" Copyright (c) 1990, 1991, 1993
3 .\" The Regents of the University of California. All rights reserved.
5 .\" This code is derived from software contributed to Berkeley by
6 .\" Chris Torek and the American National Standards Committee X3,
7 .\" on Information Processing Systems.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
17 .\" 3. All advertising materials mentioning features or use of this software
18 .\" must display the following acknowledgement:
19 .\" This product includes software developed by the University of
20 .\" California, Berkeley and its contributors.
21 .\" 4. Neither the name of the University nor the names of its contributors
22 .\" may be used to endorse or promote products derived from this software
23 .\" without specific prior written permission.
25 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 .\" @(#)scanf.3 8.2 (Berkeley) 12/11/93
38 .\" FreeBSD: src/lib/libc/stdio/scanf.3,v 1.24 2003/06/28 09:03:25 das Exp
39 .\" $FreeBSD: src/lib/libc/stdio/wscanf.3,v 1.6 2003/07/05 07:47:55 tjr Exp $
51 .Nd wide character input format conversion
58 .Fn wscanf "const wchar_t * restrict format" ...
60 .Fn fwscanf "FILE * restrict stream" "const wchar_t * restrict format" ...
62 .Fn swscanf "const wchar_t * restrict str" "const wchar_t * restrict format" ...
65 .Fn vwscanf "const wchar_t * restrict format" "va_list ap"
67 .Fn vswscanf "const wchar_t * restrict str" "const wchar_t * restrict format" "va_list ap"
69 .Fn vfwscanf "FILE * restrict stream" "const wchar_t * restrict format" "va_list ap"
73 family of functions scans input according to a
76 This format may contain
77 .Em conversion specifiers ;
78 the results from such conversions, if any,
79 are stored through the
85 reads input from the standard input stream
88 reads input from the stream pointer
92 reads its input from the wide-character string pointed to by
99 and reads input from the stream pointer
101 using a variable argument list of pointers (see
105 function scans a variable argument list from the standard input and
108 function scans it from a wide-character string;
109 these are analogous to
114 functions respectively.
117 argument must correspond properly with
118 each successive conversion specifier
122 All conversions are introduced by the
124 (percent sign) character.
128 may also contain other characters.
129 White space (such as blanks, tabs, or newlines) in the
131 string match any amount of white space, including none, in the input.
135 when an input character does not match such a format character.
137 when an input conversion cannot be made (see below).
141 character introducing a conversion
142 there may be a number of
144 characters, as follows:
145 .Bl -tag -width ".Cm l No (ell)"
147 Suppresses assignment.
148 The conversion that follows occurs as usual, but no pointer is used;
149 the result of the conversion is simply discarded.
151 Indicates that the conversion will be one of
155 and the next pointer is a pointer to a
160 Indicates that the conversion will be one of
164 and the next pointer is a pointer to a
169 Indicates that the conversion will be one of
173 and the next pointer is a pointer to a
177 that the conversion will be one of
181 and the next pointer is a pointer to
185 or that the conversion will be one of
189 and the next pointer is a pointer to an array of
193 .It Cm ll No (ell ell)
194 Indicates that the conversion will be one of
198 and the next pointer is a pointer to a
203 Indicates that the conversion will be one of
207 and the next pointer is a pointer to
210 Indicates that the conversion will be one of
214 and the next pointer is a pointer to a
219 Indicates that the conversion will be one of
223 and the next pointer is a pointer to a
228 Indicates that the conversion will be one of
232 and the next pointer is a pointer to a
238 Indicates that the conversion will be one of
242 and the next pointer is a pointer to a
248 In addition to these flags,
249 there may be an optional maximum field width,
250 expressed as a decimal integer,
254 If no width is given,
257 is used (with one exception, below);
258 otherwise at most this many characters are scanned
259 in processing the conversion.
260 Before conversion begins,
261 most conversions skip white space;
262 this white space is not counted against the field width.
264 The following conversions are available:
272 matches a single input
275 No conversion is done, and assignment does not occur.
277 Matches an optionally signed decimal integer;
278 the next pointer must be a pointer to
281 Matches an optionally signed integer;
282 the next pointer must be a pointer to
284 The integer is read in base 16 if it begins
289 in base 8 if it begins with
291 and in base 10 otherwise.
292 Only characters that correspond to the base are used.
294 Matches an octal integer;
295 the next pointer must be a pointer to
298 Matches an optionally signed decimal integer;
299 the next pointer must be a pointer to
302 Matches an optionally signed hexadecimal integer;
303 the next pointer must be a pointer to
305 .It Cm a , A , e , E , f , F , g , G
306 Matches a floating-point number in the style of
308 The next pointer must be a pointer to
316 Matches a sequence of non-white-space wide characters;
317 the next pointer must be a pointer to
319 and the array must be large enough to accept the multibyte representation
320 of all the sequence and the
324 The input string stops at white space
325 or at the maximum field width, whichever occurs first.
329 qualifier is present, the next pointer must be a pointer to
331 into which the input will be placed.
336 Matches a sequence of
339 wide characters (default 1);
340 the next pointer must be a pointer to
342 and there must be enough room for the multibyte representation
343 of all the characters
347 The usual skip of leading white space is suppressed.
348 To skip white space first, use an explicit space in the format.
352 qualifier is present, the next pointer must be a pointer to
354 into which the input will be placed.
359 Matches a nonempty sequence of characters from the specified set
360 of accepted characters;
361 the next pointer must be a pointer to
363 and there must be enough room for the multibyte representation of
364 all the characters in the string,
368 The usual skip of leading white space is suppressed.
369 The string is to be made up of characters in
372 the set is defined by the characters between the open bracket
381 if the first character after the open bracket is a circumflex
383 To include a close bracket in the set,
384 make it the first character after the open bracket
386 any other position will end the set.
387 To include a hyphen in the set,
388 make it the last character before the final close bracket;
389 some implementations of
393 to represent the range of characters between
397 The string ends with the appearance of a character not in the
398 (or, with a circumflex, in) set
399 or when the field width runs out.
403 qualifier is present, the next pointer must be a pointer to
405 into which the input will be placed.
407 Matches a pointer value (as printed by
411 the next pointer must be a pointer to
415 instead, the number of characters consumed thus far from the input
416 is stored through the next pointer,
417 which must be a pointer to
421 a conversion, although it can be suppressed with the
427 character is defined in the program's locale (category
430 For backwards compatibility, a
434 causes an immediate return of
440 the number of input items assigned, which can be fewer than provided
441 for, or even zero, in the event of a matching failure.
443 indicates that, while there was input available,
444 no conversions were assigned;
445 typically this is due to an invalid input character,
446 such as an alphabetic character for a
451 is returned if an input failure occurs before any conversion such as an
453 If an error or end-of-file occurs after conversion
455 the number of conversions which were successfully completed is returned.
477 In addition to the bugs documented in
482 notation for specifying character ranges with the character