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

Thiago Macieira thiago.macieira at intel.com
Wed Dec 26 15:16:28 CET 2012


On quarta-feira, 26 de dezembro de 2012 15.54.25, Nikos Chantziaras wrote:
> I need the actual name of the character set from which
> QFile::decodeName() is converting.  The docs say that it's the "local
> 8-bit encoding."

Yes, it's the codec that QString::to/fromLocal8Bit works on.

> I'm not sure what that means, but I suppose it's the codec returned by
> QTextCodec::codecForLocale().  Unfortunately, this:
> 
>    QTextCodec::codecForLocale()->name()

Correct.

> returns "System" on platforms that come with a Qt that uses ICU (pretty
> much all Linux distributions.)  With an ICU-less Qt build, I get the
> correct name, like "UTF-8" or "UTF-16LE", which what I need.
> 
> Is there anything I can do?  And are QFile's decodeName() and
> encodeName() functions actually using the codecForLocale() codec to
> begin with?

There is no Qt API to return that value. You can use the Windows API, POSIX 
API or ICU API to find out by yourself.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121226/3e164b99/attachment.sig>


More information about the Interest mailing list