[Interest] It is possible to get the actual name of a local character set?

Nikos Chantziaras realnc at gmail.com
Wed Dec 26 15:42:44 CET 2012


On 26/12/12 16:27, Thiago Macieira wrote:
> On quarta-feira, 26 de dezembro de 2012 16.23.30, Nikos Chantziaras wrote:
>> [...]
>> Though the API *is* there.  It's QTextCodec::name() and
>> QTextCodec::aliases().  IMO it's a mistake by Qt to return "System"
>> there, since "System" has exactly zero use.  Or at least
>> QTextCodec::aliases() should contain the actual name in one of its elements.
>
> It's not a mistake. It returns "System" meaning "I've just asked Windows or
> ICU (or in Qt 4, iconv) to do it for me and I don't care what the encoding
> was".
>
> Due to construction, in the case of ICU, the QIcuCodec class actually knows
> the name of the system codec, since it needed to ask for it via
> ucnv_getStandardName.
>
> But in the case of the Windows and iconv codecs, we simply don't know. We ask
> the system API to do it (MultiByteToWideChar, WideCharToMultiByte; iconv's
> iconv_open with a NULL source or destination).

I see.  Would be nice though if Qt would query the system for the name 
and at least return in in QTextCodec::aliases(), which shouldn't affect 
backwards compatibility.


> Why do you need the codec name anyway?

So that I can tell another library what encoding to use for filenames 
when it wants to create files.




More information about the Interest mailing list