codeset problems in wprintf and wcsftime

Andy Koppe andy.koppe@gmail.com
Sat Feb 20 16:42:00 GMT 2010


> another alternative to the solutions you outlined
> might be to store those strings as wchar versions only, to be used
> directly in wprintf and converted to the LC_CTYPE character set when
> needed in printf. That way, the user would always get readable output.
>
>> - Store the charset not only for LC_CTYPE, but for each localization
>>  category, and provide a function to request the charset.
>>  This also requires to store the associated multibyte to widechar
>>  conversion functions, obviously, and to call the correct functions
>>  from wprintf and wcftime.
>>
>> - Redefine the locale data structs so that they contain multibyte and
>>  widechar representations of all strings.  Use the multibyte strings
>>  in the multibyte functions, the widechar strings in the widechar
>>  functions.

Actually, there's a fourth alternative: do nothing.

>From http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html:
"If different character sets are used by the locale categories, the
results achieved by an application utilizing these categories are
undefined."

(So why did they even allow different charsets to be specified for
different categories!?)

Andy



More information about the Newlib mailing list