This API provides an stdio-like API wrapper around ICU's other
* formatting and parsing APIs. It is meant to ease the transition of adding
* Unicode support to a preexisting applications using stdio. The following
* is a small list of noticable differences between stdio and ICU I/O's
* ustdio implementation.
*
*
format | default printf type | default scanf type | description |
%E | double | float | Scientific with an uppercase exponent |
%e | double | float | Scientific with a lowercase exponent |
%G | double | float | Use %E or %f for best format |
%g | double | float | Use %e or %f for best format |
%f | double | float | Simple floating point without the exponent |
%X | int32_t | int32_t | ustdio special uppercase hex radix formatting |
%x | int32_t | int32_t | ustdio special lowercase hex radix formatting |
%d | int32_t | int32_t | Decimal format |
%i | int32_t | int32_t | Same as %d |
%n | int32_t | int32_t | count (write the number of UTF-16 codeunits read/written) |
%o | int32_t | int32_t | ustdio special octal radix formatting |
%u | uint32_t | uint32_t | Decimal format |
%p | void * | void * | Prints the pointer value |
%s | char * | char * | Use default converter or specified converter from fopen |
%c | char | char | Use default converter or specified converter from fopen
When width is specified for scanf, this acts like a non-NULL-terminated char * string.
By default, only one char is written. |
%S | UChar * | UChar * | Null terminated UTF-16 string |
%C | UChar | UChar | 16-bit Unicode code unit
When width is specified for scanf, this acts like a non-NULL-terminated UChar * string
By default, only one codepoint is written. |
%[] | | UChar * | Null terminated UTF-16 string which contains the filtered set of characters specified by the UnicodeSet |
%% | | | Show a percent sign |
Format modifiers
modifier | formats | type | comments |
%h | %d, %i, %o, %x | int16_t | short format |
%h | %u | uint16_t | short format |
%h | c | char | (Unimplemented) Use invariant converter |
%h | s | char * | (Unimplemented) Use invariant converter |
%h | C | char | (Unimplemented) 8-bit Unicode code unit |
%h | S | char * | (Unimplemented) Null terminated UTF-8 string |
%l | %d, %i, %o, %x | int32_t | long format (no effect) |
%l | %u | uint32_t | long format (no effect) |
%l | c | N/A | (Unimplemented) Reserved for future implementation |
%l | s | N/A | (Unimplemented) Reserved for future implementation |
%l | C | UChar32 | (Unimplemented) 32-bit Unicode code unit |
%l | S | UChar32 * | (Unimplemented) Null terminated UTF-32 string |
%ll | %d, %i, %o, %x | int64_t | long long format |
%ll | %u | uint64_t | (Unimplemented) long long format |
%- | all | N/A | Left justify |
%+ | %d, %i, %o, %x, %e, %f, %g, %E, %G | N/A | Always show the plus or minus sign. Needs data for plus sign. |
% | %d, %i, %o, %x, %e, %f, %g, %E, %G | N/A | Instead of a "+" output a blank character for positive numbers. |
%# | %d, %i, %o, %x, %e, %f, %g, %E, %G | N/A | Precede octal value with 0, hex with 0x and show the
decimal point for floats. |
%n | all | N/A | Width of input/output. num is an actual number from 0 to
some large number. |
%.n | %e, %f, %g, %E, %F, %G | N/A | Significant digits precision. num is an actual number from
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. |
printf modifier
%* int32_t Next argument after this one specifies the width
scanf modifier
%* N/A This field is scanned, but not stored
If you are using this C API instead of the ustream.h API for C++,
you can use one of the following u_fprintf examples to display a UnicodeString.