[Interest] Why there is no QChar::toLocal8Bit()?
Thiago Macieira
thiago.macieira at intel.com
Mon Apr 11 09:19:29 CEST 2016
On segunda-feira, 11 de abril de 2016 09:46:24 PDT Prav wrote:
> Hi, Thiago.
>
> > Yes. It's possible, though extremely unlikely, that the locale's encoding
> > is not 8-bit, but 16- or 32-bit. Though I think that a lot of software
> > would break
>
> Sure I am aware of it.
>
> > , so you're not going to see that.
>
> Why you think I want to "see that". Its Qt-devs naming mistake.
Indeed. It should have been called "toLocaleEncoding".
> So it is only decision of Qt-devs (probably yours) when and whether to fix
> it (may be like it was done with toAscii in Qt 5.0 ... it would be done in
> Qt 6.0 ... who knows).
Unlikely.
> But naming mistakes are worth to be fixed in docs, IMO
>
> > Anyway, the point is that it's very frequently a multibyte 8-bit encoding.
>
> Ok ok :) :) :)
>
>
> And last question ... is there a way to find out what type of encoding was
> done by toLocal8Bit? sigle-byte or multi-byte or 16- or 32-bit
As I said, it's not 16- or 32-bit because that's going to break other
software. So it's 8-bit.
Whether it's single-byte or multi-byte, you can't get that information. More
to the point, I'd say that you should not even ask that question. That
indicates you're making wrong decisions and your software has design flaws.
Instead, redesign so you don't need to answer the question in the first place.
> I was thinking about: QTextCodec::codecForLocale()-> ...
> But I did not found anything helpful in QTextCodec for that purpose.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list