2 ******************************************************************************
4 * Copyright (C) 1998-2006, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
11 * Modification History:
13 * Date Name Description
14 * 10/16/98 stephen Creation.
15 * 11/06/98 stephen Modified per code review.
16 * 03/12/99 stephen Modified for new C API.
17 * 07/19/99 stephen Minor doc update.
18 * 02/01/01 george Added sprintf & sscanf with all of its variants
19 ******************************************************************************
28 #include "unicode/utypes.h"
29 #include "unicode/ucnv.h"
30 #include "unicode/utrans.h"
34 The following is a small list as to what is currently wrong/suggestions for
37 * Make sure that * in the scanf format specification works for all formats.
38 * Each UFILE takes up at least 2KB.
39 Look into adding setvbuf() for configurable buffers.
40 * This library does buffering. The OS should do this for us already. Check on
41 this, and remove it from this library, if this is the case. Double buffering
42 wastes a lot of time and space.
43 * Test stdin and stdout with the u_f* functions
44 * Testing should be done for reading and writing multi-byte encodings,
45 and make sure that a character that is contained across buffer boundries
46 works even for incomplete characters.
47 * Make sure that the last character is flushed when the file/string is closed.
48 * snprintf should follow the C99 standard for the return value, which is
49 return the number of characters (excluding the trailing '\0')
50 which would have been written to the destination string regardless
51 of available space. This is like pre-flighting.
52 * Everything that uses %s should do what operator>> does for UnicodeString.
53 It should convert one byte at a time, and once a character is
54 converted then check to see if it's whitespace or in the scanset.
55 If it's whitespace or in the scanset, put all the bytes back (do nothing
57 * If bad string data is encountered, make sure that the function fails
58 without memory leaks and the unconvertable characters are valid
59 substitution or are escaped characters.
60 * u_fungetc() can't unget a character when it's at the beginning of the
61 internal conversion buffer. For example, read the buffer size # of
62 characters, and then ungetc to get the previous character that was
63 at the end of the last buffer.
64 * u_fflush() and u_fclose should return an int32_t like C99 functions.
65 0 is returned if the operation was successful and EOF otherwise.
66 * u_fsettransliterator does not support U_READ side of transliteration.
67 * The format specifier should limit the size of a format or honor it in
68 order to prevent buffer overruns. (e.g. %256.256d).
69 * u_fread and u_fwrite don't exist. They're needed for reading and writing
70 data structures without any conversion.
71 * u_file_read and u_file_write are used for writing strings. u_fgets and
72 u_fputs or u_fread and u_fwrite should be used to do this.
73 * The width parameter for all scanf formats, including scanset, needs
74 better testing. This prevents buffer overflows.
75 * Figure out what is suppose to happen when a codepage is changed midstream.
76 Maybe a flush or a rewind are good enough.
77 * Make sure that a UFile opened with "rw" can be used after using
78 u_fflush with a u_frewind.
79 * scanf(%i) should detect what type of number to use.
80 * Add more testing of the alternate format, %#
81 * Look at newline handling of fputs/puts
82 * Think more about codeunit/codepoint error handling/support in %S,%s,%C,%c,%[]
83 * Complete the file documentation with proper doxygen formatting.
84 See http://oss.software.ibm.com/pipermail/icu/2003-July/005647.html
89 * \brief C API: Unicode stdio-like API
91 * <h2>Unicode stdio-like C API</h2>
93 * <p>This API provides an stdio-like API wrapper around ICU's other
94 * formatting and parsing APIs. It is meant to ease the transition of adding
95 * Unicode support to a preexisting applications using stdio. The following
96 * is a small list of noticable differences between stdio and ICU I/O's
97 * ustdio implementation.</p>
100 * <li>Locale specific formatting and parsing is only done with file IO.</li>
101 * <li>u_fstropen can be used to simulate file IO with strings.
102 * This is similar to the iostream API, and it allows locale specific
103 * formatting and parsing to be used.</li>
104 * <li>This API provides uniform formatting and parsing behavior between
105 * platforms (unlike the standard stdio implementations found on various
107 * <li>This API is better suited for text data handling than binary data
108 * handling when compared to the typical stdio implementation.</li>
109 * <li>You can specify a Transliterator while using the file IO.</li>
110 * <li>You can specify a file's codepage separately from the default
111 * system codepage.</li>
114 * <h2>Formatting and Parsing Specification</h2>
116 * General printf format:<br>
117 * %[format modifier][width][.precision][type modifier][format]
119 * General scanf format:<br>
120 * %[*][format modifier][width][type modifier][format]
122 <table cellspacing="3">
123 <tr><td>format</td><td>default<br>printf<br>type</td><td>default<br>scanf<br>type</td><td>description</td></tr>
124 <tr><td>%E</td><td>double</td><td>float</td><td>Scientific with an uppercase exponent</td></tr>
125 <tr><td>%e</td><td>double</td><td>float</td><td>Scientific with a lowercase exponent</td></tr>
126 <tr><td>%G</td><td>double</td><td>float</td><td>Use %E or %f for best format</td></tr>
127 <tr><td>%g</td><td>double</td><td>float</td><td>Use %e or %f for best format</td></tr>
128 <tr><td>%f</td><td>double</td><td>float</td><td>Simple floating point without the exponent</td></tr>
129 <tr><td>%X</td><td>int32_t</td><td>int32_t</td><td>ustdio special uppercase hex radix formatting</td></tr>
130 <tr><td>%x</td><td>int32_t</td><td>int32_t</td><td>ustdio special lowercase hex radix formatting</td></tr>
131 <tr><td>%d</td><td>int32_t</td><td>int32_t</td><td>Decimal format</td></tr>
132 <tr><td>%i</td><td>int32_t</td><td>int32_t</td><td>Same as %d</td></tr>
133 <tr><td>%n</td><td>int32_t</td><td>int32_t</td><td>count (write the number of UTF-16 codeunits read/written)</td></tr>
134 <tr><td>%o</td><td>int32_t</td><td>int32_t</td><td>ustdio special octal radix formatting</td></tr>
135 <tr><td>%u</td><td>uint32_t</td><td>uint32_t</td><td>Decimal format</td></tr>
136 <tr><td>%p</td><td>void *</td><td>void *</td><td>Prints the pointer value</td></tr>
137 <tr><td>%s</td><td>char *</td><td>char *</td><td>Use default converter or specified converter from fopen</td></tr>
138 <tr><td>%c</td><td>char</td><td>char</td><td>Use default converter or specified converter from fopen<br>
139 When width is specified for scanf, this acts like a non-NULL-terminated char * string.<br>
140 By default, only one char is written.</td></tr>
141 <tr><td>%S</td><td>UChar *</td><td>UChar *</td><td>Null terminated UTF-16 string</td></tr>
142 <tr><td>%C</td><td>UChar</td><td>UChar</td><td>16-bit Unicode code unit<br>
143 When width is specified for scanf, this acts like a non-NULL-terminated UChar * string<br>
144 By default, only one codepoint is written.</td></tr>
145 <tr><td>%[]</td><td> </td><td>UChar *</td><td>Null terminated UTF-16 string which contains the filtered set of characters specified by the UnicodeSet</td></tr>
146 <tr><td>%%</td><td> </td><td> </td><td>Show a percent sign</td></tr>
151 <tr><td>modifier</td><td>formats</td><td>type</td><td>comments</td></tr>
152 <tr><td>%h</td><td>%d, %i, %o, %x</td><td>int16_t</td><td>short format</td></tr>
153 <tr><td>%h</td><td>%u</td><td>uint16_t</td><td>short format</td></tr>
154 <tr><td>%h</td><td>c</td><td>char</td><td><b>(Unimplemented)</b> Use invariant converter</td></tr>
155 <tr><td>%h</td><td>s</td><td>char *</td><td><b>(Unimplemented)</b> Use invariant converter</td></tr>
156 <tr><td>%h</td><td>C</td><td>char</td><td><b>(Unimplemented)</b> 8-bit Unicode code unit</td></tr>
157 <tr><td>%h</td><td>S</td><td>char *</td><td><b>(Unimplemented)</b> Null terminated UTF-8 string</td></tr>
158 <tr><td>%l</td><td>%d, %i, %o, %x</td><td>int32_t</td><td>long format (no effect)</td></tr>
159 <tr><td>%l</td><td>%u</td><td>uint32_t</td><td>long format (no effect)</td></tr>
160 <tr><td>%l</td><td>c</td><td>N/A</td><td><b>(Unimplemented)</b> Reserved for future implementation</td></tr>
161 <tr><td>%l</td><td>s</td><td>N/A</td><td><b>(Unimplemented)</b> Reserved for future implementation</td></tr>
162 <tr><td>%l</td><td>C</td><td>UChar32</td><td><b>(Unimplemented)</b> 32-bit Unicode code unit</td></tr>
163 <tr><td>%l</td><td>S</td><td>UChar32 *</td><td><b>(Unimplemented)</b> Null terminated UTF-32 string</td></tr>
164 <tr><td>%ll</td><td>%d, %i, %o, %x</td><td>int64_t</td><td>long long format</td></tr>
165 <tr><td>%ll</td><td>%u</td><td>uint64_t</td><td><b>(Unimplemented)</b> long long format</td></tr>
166 <tr><td>%-</td><td><i>all</i></td><td>N/A</td><td>Left justify</td></tr>
167 <tr><td>%+</td><td>%d, %i, %o, %x, %e, %f, %g, %E, %G</td><td>N/A</td><td>Always show the plus or minus sign. Needs data for plus sign.</td></tr>
168 <tr><td>% </td><td>%d, %i, %o, %x, %e, %f, %g, %E, %G</td><td>N/A</td><td>Instead of a "+" output a blank character for positive numbers.</td></tr>
169 <tr><td>%#</td><td>%d, %i, %o, %x, %e, %f, %g, %E, %G</td><td>N/A</td><td>Precede octal value with 0, hex with 0x and show the
170 decimal point for floats.</td></tr>
171 <tr><td>%<i>n</i></td><td><i>all</i></td><td>N/A</td><td>Width of input/output. num is an actual number from 0 to
172 some large number.</td></tr>
173 <tr><td>%.<i>n</i></td><td>%e, %f, %g, %E, %F, %G</td><td>N/A</td><td>Significant digits precision. num is an actual number from
174 0 to some large number.<br>If * is used in printf, then the precision is passed in as an argument before the number to be formatted.</td></tr>
178 %* int32_t Next argument after this one specifies the width
181 %* N/A This field is scanned, but not stored
187 * When an end of file is encountered, this value can be returned.
193 /** Forward declaration of a Unicode-aware file @stable 3.0 */
194 typedef struct UFILE UFILE
;
196 #ifndef U_HIDE_DRAFT_API
198 * Enum for which direction of stream a transliterator applies to.
199 * @see u_fsettransliterator
205 U_READWRITE
=3 /* == (U_READ | U_WRITE) */
208 #endif /* U_HIDE_DRAFT_API */
212 * A UFILE is a wrapper around a FILE* that is locale and codepage aware.
213 * That is, data written to a UFILE will be formatted using the conventions
214 * specified by that UFILE's Locale; this data will be in the character set
215 * specified by that UFILE's codepage.
216 * @param filename The name of the file to open.
217 * @param perm The read/write permission for the UFILE; one of "r", "w", "rw"
218 * @param locale The locale whose conventions will be used to format
219 * and parse output. If this parameter is NULL, the default locale will
221 * @param codepage The codepage in which data will be written to and
222 * read from the file. If this paramter is NULL the system default codepage
224 * @return A new UFILE, or NULL if an error occurred.
227 U_DRAFT UFILE
* U_EXPORT2
228 u_fopen(const char *filename
,
231 const char *codepage
);
234 * Open a UFILE on top of an existing FILE* stream.
235 * @param f The FILE* to which this UFILE will attach.
236 * @param locale The locale whose conventions will be used to format
237 * and parse output. If this parameter is NULL, the default locale will
239 * @param codepage The codepage in which data will be written to and
240 * read from the file. If this paramter is NULL, data will be written and
241 * read using the default codepage for <TT>locale</TT>, unless <TT>locale</TT>
242 * is NULL, in which case the system default codepage will be used.
243 * @return A new UFILE, or NULL if an error occurred.
246 U_DRAFT UFILE
* U_EXPORT2
249 const char *codepage
);
252 * Create a UFILE that can be used for localized formatting or parsing.
253 * The u_sprintf and u_sscanf functions do not read or write numbers for a
254 * specific locale. The ustdio.h file functions can be used on this UFILE.
255 * The string is usable once u_fclose or u_fflush has been called on the
257 * @param stringBuf The string used for reading or writing.
258 * @param capacity The number of code units available for use in stringBuf
259 * @param locale The locale whose conventions will be used to format
260 * and parse output. If this parameter is NULL, the default locale will
262 * @return A new UFILE, or NULL if an error occurred.
265 U_DRAFT UFILE
* U_EXPORT2
266 u_fstropen(UChar
*stringBuf
,
272 * @param file The UFILE to close.
275 U_DRAFT
void U_EXPORT2
276 u_fclose(UFILE
*file
);
279 * Tests if the UFILE is at the end of the file stream.
280 * @param f The UFILE from which to read.
281 * @return Returns TRUE after the first read operation that attempts to
282 * read past the end of the file. It returns FALSE if the current position is
286 U_DRAFT UBool U_EXPORT2
290 * Flush output of a UFILE. Implies a flush of
291 * converter/transliterator state. (That is, a logical break is
292 * made in the output stream - for example if a different type of
293 * output is desired.) The underlying OS level file is also flushed.
294 * @param file The UFILE to flush.
297 U_DRAFT
void U_EXPORT2
298 u_fflush(UFILE
*file
);
301 * Rewind the file pointer to the beginning of the file.
302 * @param file The UFILE to rewind.
306 u_frewind(UFILE
*file
);
309 * Get the FILE* associated with a UFILE.
311 * @return A FILE*, owned by the UFILE. The FILE <EM>must not</EM> be closed.
314 U_DRAFT
FILE* U_EXPORT2
315 u_fgetfile(UFILE
*f
);
317 #if !UCONFIG_NO_FORMATTING
320 * Get the locale whose conventions are used to format and parse output.
321 * This is the same locale passed in the preceding call to<TT>u_fsetlocale</TT>
322 * or <TT>u_fopen</TT>.
323 * @param file The UFILE to set.
324 * @return The locale whose conventions are used to format and parse output.
327 U_DRAFT
const char* U_EXPORT2
328 u_fgetlocale(UFILE
*file
);
331 * Set the locale whose conventions will be used to format and parse output.
332 * @param locale The locale whose conventions will be used to format
334 * @param file The UFILE to query.
335 * @return NULL if successful, otherwise a negative number.
338 U_DRAFT
int32_t U_EXPORT2
339 u_fsetlocale(UFILE
*file
,
345 * Get the codepage in which data is written to and read from the UFILE.
346 * This is the same codepage passed in the preceding call to
347 * <TT>u_fsetcodepage</TT> or <TT>u_fopen</TT>.
348 * @param file The UFILE to query.
349 * @return The codepage in which data is written to and read from the UFILE,
350 * or NULL if an error occurred.
353 U_DRAFT
const char* U_EXPORT2
354 u_fgetcodepage(UFILE
*file
);
357 * Set the codepage in which data will be written to and read from the UFILE.
358 * All Unicode data written to the UFILE will be converted to this codepage
359 * before it is written to the underlying FILE*. It it generally a bad idea to
360 * mix codepages within a file. This should only be called right
361 * after opening the <TT>UFile</TT>, or after calling <TT>u_frewind</TT>.
362 * @param codepage The codepage in which data will be written to
363 * and read from the file. For example <TT>"latin-1"</TT> or <TT>"ibm-943</TT>.
364 * A value of NULL means the default codepage for the UFILE's current
365 * locale will be used.
366 * @param file The UFILE to set.
367 * @return 0 if successful, otherwise a negative number.
371 U_DRAFT
int32_t U_EXPORT2
372 u_fsetcodepage(const char *codepage
,
377 * Returns an alias to the converter being used for this file.
378 * @param f The UFILE to get the value from
379 * @return alias to the converter
382 U_DRAFT UConverter
* U_EXPORT2
u_fgetConverter(UFILE
*f
);
384 #if !UCONFIG_NO_FORMATTING
386 /* Output functions */
389 * Write formatted data to a UFILE.
390 * @param f The UFILE to which to write.
391 * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
392 * interpret the variable arguments received and format the data.
393 * @return The number of Unicode characters written to <TT>f</TT>.
396 U_DRAFT
int32_t U_EXPORT2
398 const char *patternSpecification
,
402 * Write formatted data to a UFILE.
403 * This is identical to <TT>u_fprintf</TT>, except that it will
404 * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
405 * @param f The UFILE to which to write.
406 * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
407 * interpret the variable arguments received and format the data.
408 * @param ap The argument list to use.
409 * @return The number of Unicode characters written to <TT>f</TT>.
413 U_DRAFT
int32_t U_EXPORT2
415 const char *patternSpecification
,
419 * Write formatted data to a UFILE.
420 * @param f The UFILE to which to write.
421 * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
422 * interpret the variable arguments received and format the data.
423 * @return The number of Unicode characters written to <TT>f</TT>.
426 U_DRAFT
int32_t U_EXPORT2
427 u_fprintf_u(UFILE
*f
,
428 const UChar
*patternSpecification
,
432 * Write formatted data to a UFILE.
433 * This is identical to <TT>u_fprintf_u</TT>, except that it will
434 * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
435 * @param f The UFILE to which to write.
436 * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
437 * interpret the variable arguments received and format the data.
438 * @param ap The argument list to use.
439 * @return The number of Unicode characters written to <TT>f</TT>.
443 U_DRAFT
int32_t U_EXPORT2
444 u_vfprintf_u(UFILE
*f
,
445 const UChar
*patternSpecification
,
449 * Write a Unicode to a UFILE. The null (U+0000) terminated UChar*
450 * <TT>s</TT> will be written to <TT>f</TT>, excluding the NULL terminator.
451 * A newline will be added to <TT>f</TT>.
452 * @param s The UChar* to write.
453 * @param f The UFILE to which to write.
454 * @return A non-negative number if successful, EOF otherwise.
458 U_DRAFT
int32_t U_EXPORT2
459 u_fputs(const UChar
*s
,
463 * Write a UChar to a UFILE.
464 * @param uc The UChar to write.
465 * @param f The UFILE to which to write.
466 * @return The character written if successful, EOF otherwise.
469 U_DRAFT UChar32 U_EXPORT2
474 * Write Unicode to a UFILE.
475 * The ustring passed in will be converted to the UFILE's underlying
476 * codepage before it is written.
477 * @param ustring A pointer to the Unicode data to write.
478 * @param count The number of Unicode characters to write
479 * @param f The UFILE to which to write.
480 * @return The number of Unicode characters written.
484 U_DRAFT
int32_t U_EXPORT2
485 u_file_write(const UChar
*ustring
,
490 /* Input functions */
491 #if !UCONFIG_NO_FORMATTING
494 * Read formatted data from a UFILE.
495 * @param f The UFILE from which to read.
496 * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
497 * interpret the variable arguments received and parse the data.
498 * @return The number of items successfully converted and assigned, or EOF
499 * if an error occurred.
502 U_DRAFT
int32_t U_EXPORT2
504 const char *patternSpecification
,
508 * Read formatted data from a UFILE.
509 * This is identical to <TT>u_fscanf</TT>, except that it will
510 * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
511 * @param f The UFILE from which to read.
512 * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
513 * interpret the variable arguments received and parse the data.
514 * @param ap The argument list to use.
515 * @return The number of items successfully converted and assigned, or EOF
516 * if an error occurred.
520 U_DRAFT
int32_t U_EXPORT2
522 const char *patternSpecification
,
526 * Read formatted data from a UFILE.
527 * @param f The UFILE from which to read.
528 * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
529 * interpret the variable arguments received and parse the data.
530 * @return The number of items successfully converted and assigned, or EOF
531 * if an error occurred.
534 U_DRAFT
int32_t U_EXPORT2
536 const UChar
*patternSpecification
,
540 * Read formatted data from a UFILE.
541 * This is identical to <TT>u_fscanf_u</TT>, except that it will
542 * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
543 * @param f The UFILE from which to read.
544 * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
545 * interpret the variable arguments received and parse the data.
546 * @param ap The argument list to use.
547 * @return The number of items successfully converted and assigned, or EOF
548 * if an error occurred.
552 U_DRAFT
int32_t U_EXPORT2
553 u_vfscanf_u(UFILE
*f
,
554 const UChar
*patternSpecification
,
559 * Read one line of text into a UChar* string from a UFILE. The newline
560 * at the end of the line is read into the string. The string is always
562 * @param f The UFILE from which to read.
563 * @param n The maximum number of characters - 1 to read.
564 * @param s The UChar* to receive the read data. Characters will be
565 * stored successively in <TT>s</TT> until a newline or EOF is
566 * reached. A null character (U+0000) will be appended to <TT>s</TT>.
567 * @return A pointer to <TT>s</TT>, or NULL if no characters were available.
570 U_DRAFT UChar
* U_EXPORT2
576 * Read a UChar from a UFILE. It is recommended that <TT>u_fgetcx</TT>
577 * used instead for proper parsing functions, but sometimes reading
578 * code units is needed instead of codepoints.
580 * @param f The UFILE from which to read.
581 * @return The UChar value read, or U+FFFF if no character was available.
584 U_DRAFT UChar U_EXPORT2
588 * Read a UChar32 from a UFILE.
590 * @param f The UFILE from which to read.
591 * @return The UChar32 value read, or U_EOF if no character was
592 * available, or U+FFFFFFFF if an ill-formed character was
597 U_DRAFT UChar32 U_EXPORT2
601 * Unget a UChar from a UFILE.
602 * If this function is not the first to operate on <TT>f</TT> after a call
603 * to <TT>u_fgetc</TT>, the results are undefined.
604 * If this function is passed a character that was not recieved from the
605 * previous <TT>u_fgetc</TT> or <TT>u_fgetcx</TT> call, the results are undefined.
606 * @param c The UChar to put back on the stream.
607 * @param f The UFILE to receive <TT>c</TT>.
608 * @return The UChar32 value put back if successful, U_EOF otherwise.
611 U_DRAFT UChar32 U_EXPORT2
616 * Read Unicode from a UFILE.
617 * Bytes will be converted from the UFILE's underlying codepage, with
618 * subsequent conversion to Unicode. The data will not be NULL terminated.
619 * @param chars A pointer to receive the Unicode data.
620 * @param count The number of Unicode characters to read.
621 * @param f The UFILE from which to read.
622 * @return The number of Unicode characters read.
625 U_DRAFT
int32_t U_EXPORT2
626 u_file_read(UChar
*chars
,
630 #if !UCONFIG_NO_TRANSLITERATION
633 * Set a transliterator on the UFILE. The transliterator will be owned by the
635 * @param file The UFILE to set transliteration on
636 * @param adopt The UTransliterator to set. Can be NULL, which will
637 * mean that no transliteration is used.
638 * @param direction either U_READ, U_WRITE, or U_READWRITE - sets
639 * which direction the transliterator is to be applied to. If
640 * U_READWRITE, the "Read" transliteration will be in the inverse
642 * @param status ICU error code.
643 * @return The previously set transliterator, owned by the
644 * caller. If U_READWRITE is specified, only the WRITE transliterator
645 * is returned. In most cases, the caller should call utrans_close()
646 * on the result of this function.
649 U_DRAFT UTransliterator
* U_EXPORT2
650 u_fsettransliterator(UFILE
*file
, UFileDirection direction
,
651 UTransliterator
*adopt
, UErrorCode
*status
);
656 /* Output string functions */
657 #if !UCONFIG_NO_FORMATTING
661 * Write formatted data to a Unicode string.
663 * @param buffer The Unicode String to which to write.
664 * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
665 * interpret the variable arguments received and format the data.
666 * @return The number of Unicode code units written to <TT>buffer</TT>. This
667 * does not include the terminating null character.
670 U_DRAFT
int32_t U_EXPORT2
671 u_sprintf(UChar
*buffer
,
672 const char *patternSpecification
,
676 * Write formatted data to a Unicode string. When the number of code units
677 * required to store the data exceeds <TT>count</TT>, then <TT>count</TT> code
678 * units of data are stored in <TT>buffer</TT> and a negative value is
679 * returned. When the number of code units required to store the data equals
680 * <TT>count</TT>, the string is not null terminated and <TT>count</TT> is
683 * @param buffer The Unicode String to which to write.
684 * @param count The number of code units to read.
685 * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
686 * interpret the variable arguments received and format the data.
687 * @return The number of Unicode code units written to <TT>buffer</TT>. This
688 * does not include the terminating null character.
691 U_DRAFT
int32_t U_EXPORT2
692 u_snprintf(UChar
*buffer
,
694 const char *patternSpecification
,
698 * Write formatted data to a Unicode string.
699 * This is identical to <TT>u_sprintf</TT>, except that it will
700 * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
702 * @param buffer The Unicode string to which to write.
703 * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
704 * interpret the variable arguments received and format the data.
705 * @param ap The argument list to use.
706 * @return The number of Unicode characters written to <TT>buffer</TT>.
710 U_DRAFT
int32_t U_EXPORT2
711 u_vsprintf(UChar
*buffer
,
712 const char *patternSpecification
,
716 * Write formatted data to a Unicode string.
717 * This is identical to <TT>u_snprintf</TT>, except that it will
718 * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.<br><br>
719 * When the number of code units required to store the data exceeds
720 * <TT>count</TT>, then <TT>count</TT> code units of data are stored in
721 * <TT>buffer</TT> and a negative value is returned. When the number of code
722 * units required to store the data equals <TT>count</TT>, the string is not
723 * null terminated and <TT>count</TT> is returned.
725 * @param buffer The Unicode string to which to write.
726 * @param count The number of code units to read.
727 * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
728 * interpret the variable arguments received and format the data.
729 * @param ap The argument list to use.
730 * @return The number of Unicode characters written to <TT>buffer</TT>.
734 U_DRAFT
int32_t U_EXPORT2
735 u_vsnprintf(UChar
*buffer
,
737 const char *patternSpecification
,
741 * Write formatted data to a Unicode string.
743 * @param buffer The Unicode string to which to write.
744 * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
745 * interpret the variable arguments received and format the data.
746 * @return The number of Unicode characters written to <TT>buffer</TT>.
749 U_DRAFT
int32_t U_EXPORT2
750 u_sprintf_u(UChar
*buffer
,
751 const UChar
*patternSpecification
,
755 * Write formatted data to a Unicode string. When the number of code units
756 * required to store the data exceeds <TT>count</TT>, then <TT>count</TT> code
757 * units of data are stored in <TT>buffer</TT> and a negative value is
758 * returned. When the number of code units required to store the data equals
759 * <TT>count</TT>, the string is not null terminated and <TT>count</TT> is
762 * @param buffer The Unicode string to which to write.
763 * @param count The number of code units to read.
764 * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
765 * interpret the variable arguments received and format the data.
766 * @return The number of Unicode characters written to <TT>buffer</TT>.
769 U_DRAFT
int32_t U_EXPORT2
770 u_snprintf_u(UChar
*buffer
,
772 const UChar
*patternSpecification
,
776 * Write formatted data to a Unicode string.
777 * This is identical to <TT>u_sprintf_u</TT>, except that it will
778 * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
780 * @param buffer The Unicode string to which to write.
781 * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
782 * interpret the variable arguments received and format the data.
783 * @param ap The argument list to use.
784 * @return The number of Unicode characters written to <TT>f</TT>.
788 U_DRAFT
int32_t U_EXPORT2
789 u_vsprintf_u(UChar
*buffer
,
790 const UChar
*patternSpecification
,
794 * Write formatted data to a Unicode string.
795 * This is identical to <TT>u_snprintf_u</TT>, except that it will
796 * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
797 * When the number of code units required to store the data exceeds
798 * <TT>count</TT>, then <TT>count</TT> code units of data are stored in
799 * <TT>buffer</TT> and a negative value is returned. When the number of code
800 * units required to store the data equals <TT>count</TT>, the string is not
801 * null terminated and <TT>count</TT> is returned.
803 * @param buffer The Unicode string to which to write.
804 * @param count The number of code units to read.
805 * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
806 * interpret the variable arguments received and format the data.
807 * @param ap The argument list to use.
808 * @return The number of Unicode characters written to <TT>f</TT>.
812 U_DRAFT
int32_t U_EXPORT2
813 u_vsnprintf_u(UChar
*buffer
,
815 const UChar
*patternSpecification
,
818 /* Input string functions */
821 * Read formatted data from a Unicode string.
823 * @param buffer The Unicode string from which to read.
824 * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
825 * interpret the variable arguments received and parse the data.
826 * @return The number of items successfully converted and assigned, or EOF
827 * if an error occurred.
830 U_DRAFT
int32_t U_EXPORT2
831 u_sscanf(const UChar
*buffer
,
832 const char *patternSpecification
,
836 * Read formatted data from a Unicode string.
837 * This is identical to <TT>u_sscanf</TT>, except that it will
838 * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
840 * @param buffer The Unicode string from which to read.
841 * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
842 * interpret the variable arguments received and parse the data.
843 * @param ap The argument list to use.
844 * @return The number of items successfully converted and assigned, or EOF
845 * if an error occurred.
849 U_DRAFT
int32_t U_EXPORT2
850 u_vsscanf(const UChar
*buffer
,
851 const char *patternSpecification
,
855 * Read formatted data from a Unicode string.
857 * @param buffer The Unicode string from which to read.
858 * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
859 * interpret the variable arguments received and parse the data.
860 * @return The number of items successfully converted and assigned, or EOF
861 * if an error occurred.
864 U_DRAFT
int32_t U_EXPORT2
865 u_sscanf_u(const UChar
*buffer
,
866 const UChar
*patternSpecification
,
870 * Read formatted data from a Unicode string.
871 * This is identical to <TT>u_sscanf_u</TT>, except that it will
872 * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
874 * @param buffer The Unicode string from which to read.
875 * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
876 * interpret the variable arguments received and parse the data.
877 * @param ap The argument list to use.
878 * @return The number of items successfully converted and assigned, or EOF
879 * if an error occurred.
883 U_DRAFT
int32_t U_EXPORT2
884 u_vsscanf_u(const UChar
*buffer
,
885 const UChar
*patternSpecification
,