[Interest] QVariantMap: constEnd() not equal to end()?
Thiago Macieira
thiago.macieira at intel.com
Wed Apr 1 01:50:45 CEST 2015
On Wednesday 01 April 2015 10:35:20 Hamish Moffatt wrote:
> What's the benefit of QT_NO_CAST_FROM_ASCII though? I tried, but gave up
> after I saw the first million compile errors. I converted quite a few
> places to use QStringLiteral and QLatin1String, and the debug executable
> seemed to grow rapidly (MSVC 2013). Release was barely affected though.
To avoid encoding mistakes, like:
QFile f(filename);
if (f.open(QIODevice::ReadOnly)) {
QString line = f.readLine();
parse(line);
}
Every point in the source where you create a QString from an 8-bit
representation, you MUST know what the encoding that 8-bit representation is.
There are no exceptions. You MUST know, period.
If you don't set QT_NO_CAST_FROM_ASCII, you're saying that every place where
you allowed the automatic conversion to take place should use UTF-8. In the
example above, are you sure the file is encoded in UTF-8? Usually, files are
encoded in the locale's encoding...
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list