[Development] Why we *have to* remove codecFor... ?

Thiago Macieira thiago.macieira at intel.com
Sun Apr 22 12:49:59 CEST 2012


On domingo, 22 de abril de 2012 17.11.13, Loaden wrote:
> Thanks for reply! I don't care the reason now, I just want know how to make
> it work.
> I am try UTF-8 of the source file, with or not with UTF-8 BOM, and try
> fromLatin1/Utf8/Ascii too.
> And all tried is failed!

I'd like to point out that the change is not complete.

QString's constructor, fromAscii and QObject::tr will be changed to take UTF-8 
as input, plus QString's toAscii function will produce UTF-8. They currently 
operate on Latin 1 because we haven't finished the change.

So the solution to make everything work is:
 1) always use UTF-8 encoded files
 2) mark your US-ASCII strings with QLatin1String
 3) everything else will either auto-convert, or use QString::fromUtf8 or 
     QStringLiteral

Now, I *really*, *really* don't care about source code that doesn't follow 
step 1. The C++ Standards Committee decided to give us Unicode strings (a very 
modern action), but did not bother to specify the input character set for 
source code (a very 1980s action).

For that reason, considering that we live in a global world and that source 
code is often shared among people in different countries. I am assuming that 
every developer will choose to use UTF-8 given the option and that every 
compiler and every text editor can understand it with minimal pain.

Any compiler or text editor that can't understand UTF-8 (without a BOM) will 
receive from me the label of "crap" and will not take into consideration the 
problems users using them have with the plan above.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- 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/development/attachments/20120422/a6f78f3d/attachment.sig>


More information about the Development mailing list