]>
git.saurik.com Git - apple/icu.git/blob - icuSources/io/uscanf.cpp
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ******************************************************************************
6 * Copyright (C) 1998-2014, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 ******************************************************************************
13 * Modification History:
15 * Date Name Description
16 * 12/02/98 stephen Creation.
17 * 03/13/99 stephen Modified for new C API.
18 ******************************************************************************
21 #include "unicode/utypes.h"
23 #if !UCONFIG_NO_FORMATTING && !UCONFIG_NO_CONVERSION
25 #include "unicode/putil.h"
26 #include "unicode/ustdio.h"
27 #include "unicode/ustring.h"
36 U_CAPI
int32_t U_EXPORT2
38 const char *patternSpecification
,
44 va_start(ap
, patternSpecification
);
45 converted
= u_vfscanf(f
, patternSpecification
, ap
);
51 U_CAPI
int32_t U_EXPORT2
53 const UChar
*patternSpecification
,
59 va_start(ap
, patternSpecification
);
60 converted
= u_vfscanf_u(f
, patternSpecification
, ap
);
66 U_CAPI
int32_t U_EXPORT2
/* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
68 const char *patternSpecification
,
73 UChar patBuffer
[UFMT_DEFAULT_BUFFER_SIZE
];
74 int32_t size
= (int32_t)uprv_strlen(patternSpecification
) + 1;
76 /* convert from the default codepage to Unicode */
77 if (size
>= MAX_UCHAR_BUFFER_SIZE(patBuffer
)) {
78 pattern
= (UChar
*)uprv_malloc(size
* sizeof(UChar
));
86 u_charsToUChars(patternSpecification
, pattern
, size
);
89 converted
= u_vfscanf_u(f
, pattern
, ap
);
92 if (pattern
!= patBuffer
) {
99 U_CAPI
int32_t U_EXPORT2
/* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
100 u_vfscanf_u(UFILE
*f
,
101 const UChar
*patternSpecification
,
104 return u_scanf_parse(f
, patternSpecification
, ap
);
107 #endif /* #if !UCONFIG_NO_FORMATTING */