This API provides an stdio-like API wrapper around ICU's other
103 * formatting and parsing APIs. It is meant to ease the transition of adding
104 * Unicode support to a preexisting applications using stdio. The following
105 * is a small list of noticeable differences between stdio and ICU I/O's
106 * ustdio implementation.
107 *
108 *
132 format | default printf type | default scanf type | description |
133 %E | double | float | Scientific with an uppercase exponent |
134 %e | double | float | Scientific with a lowercase exponent |
135 %G | double | float | Use %E or %f for best format |
136 %g | double | float | Use %e or %f for best format |
137 %f | double | float | Simple floating point without the exponent |
138 %X | int32_t | int32_t | ustdio special uppercase hex radix formatting |
139 %x | int32_t | int32_t | ustdio special lowercase hex radix formatting |
140 %d | int32_t | int32_t | Decimal format |
141 %i | int32_t | int32_t | Same as %d |
142 %n | int32_t | int32_t | count (write the number of UTF-16 codeunits read/written) |
143 %o | int32_t | int32_t | ustdio special octal radix formatting |
144 %u | uint32_t | uint32_t | Decimal format |
145 %p | void * | void * | Prints the pointer value |
146 %s | char * | char * | Use default converter or specified converter from fopen |
147 %c | char | char | Use default converter or specified converter from fopen
148 When width is specified for scanf, this acts like a non-NULL-terminated char * string.
149 By default, only one char is written. |
150 %S | UChar * | UChar * | Null terminated UTF-16 string |
151 %C | UChar | UChar | 16-bit Unicode code unit
152 When width is specified for scanf, this acts like a non-NULL-terminated UChar * string
153 By default, only one codepoint is written. |
154 %[] | | UChar * | Null terminated UTF-16 string which contains the filtered set of characters specified by the UnicodeSet |
155 %% | | | Show a percent sign |
156
157
158 Format modifiers
159
160 modifier | formats | type | comments |
161 %h | %d, %i, %o, %x | int16_t | short format |
162 %h | %u | uint16_t | short format |
163 %h | c | char | (Unimplemented) Use invariant converter |
164 %h | s | char * | (Unimplemented) Use invariant converter |
165 %h | C | char | (Unimplemented) 8-bit Unicode code unit |
166 %h | S | char * | (Unimplemented) Null terminated UTF-8 string |
167 %l | %d, %i, %o, %x | int32_t | long format (no effect) |
168 %l | %u | uint32_t | long format (no effect) |
169 %l | c | N/A | (Unimplemented) Reserved for future implementation |
170 %l | s | N/A | (Unimplemented) Reserved for future implementation |
171 %l | C | UChar32 | (Unimplemented) 32-bit Unicode code unit |
172 %l | S | UChar32 * | (Unimplemented) Null terminated UTF-32 string |
173 %ll | %d, %i, %o, %x | int64_t | long long format |
174 %ll | %u | uint64_t | (Unimplemented) long long format |
175 %- | all | N/A | Left justify |
176 %+ | %d, %i, %o, %x, %e, %f, %g, %E, %G | N/A | Always show the plus or minus sign. Needs data for plus sign. |
177 % | %d, %i, %o, %x, %e, %f, %g, %E, %G | N/A | Instead of a "+" output a blank character for positive numbers. |
178 %# | %d, %i, %o, %x, %e, %f, %g, %E, %G | N/A | Precede octal value with 0, hex with 0x and show the
179 decimal point for floats. |
180 %n | all | N/A | Width of input/output. num is an actual number from 0 to
181 some large number. |
182 %.n | %e, %f, %g, %E, %F, %G | N/A | Significant digits precision. num is an actual number from
183 0 to some large number. If * is used in printf, then the precision is passed in as an argument before the number to be formatted. |
184
185
186 printf modifier
187 %* int32_t Next argument after this one specifies the width
188
189 scanf modifier
190 %* N/A This field is scanned, but not stored
191
192 If you are using this C API instead of the ustream.h API for C++,
193 you can use one of the following u_fprintf examples to display a UnicodeString.
194
195