ICU4C proposal: icuio API changes
George Rhoten <[email protected]> Tue, 13 Apr 2004 11:56:03 -0700
| Newsgroups | gmane.comp.lib.icu.general |
|---|---|
| Message-ID | <OF2F0618C7.480AE599-ON86256E75.0063D966-88256E75.0068088F@us.ibm.com> |
Summary
I'd like to propose removing the locale parameter from all sprintf
functions in unicode/ustdio.h, and add a new string function to allow
string formatting with the fprintf functions.
Background
The reason for this change is that most people do not need locale specific
formatting for strings. Most of the time, only "en_US_POSIX" formatting
is wanted for numbers. Also maintaining a large cache of number
formatters is a significant performance hit for the sprintf API. The
UFILE struct is much better at caching the formatters.
Migrating existing applications using printf to use the icuio functions is
made more difficult because of the extra locale parameter. Sometimes
people forget to add the locale parameter during this migration, and thus
get the arguments wrong. Some people are unaware of the purpose of the
en_US_POSIX locale. By removing this extra parameter, migration will be
easier for most people.
ICU 3.0 should be the first release of ICU where the icuio library will be
a supported library. This means that breaking API changes shouldn't be
happening in the future for this library.
Here is the new API being added:
/**
* Create a UFILE that can be used for localized formatting or parsing.
* The u_sprintf and u_sscanf functions do not read or write numbers for a
* specific locale. The ustdio.h file functions can be used on this UFILE.
* @param locale The locale whose conventions will be used to format
* and parse output. If this parameter is NULL, the default locale will
* be used.
* @param stringBuf The string used for reading or writing.
* @param count The number of code units available for use in stringBuf
* @return A new UFILE, or NULL if an error occurred.
* @draft 3.0
*/
U_CAPI UFILE* U_EXPORT2
u_stropen(const char *locale,
const UChar *stringBuf,
int32_t capacity);
Deadline for comments: April 20, 2004
George Rhoten
IBM Globalization Center of Competency/ICU San José, CA, USA
ICU main website: http://oss.software.ibm.com/icu/index.html