Encoding problems due to automatic QByteArray <-> QString casting
Milian Wolff
mail at milianw.de
Wed Jul 22 14:39:08 UTC 2009
Milian Wolff wrote:
> See also: https://bugs.kde.org/show_bug.cgi?id=183182
>
> The problem here is that QString has a ctor which converts a QByteArray
> implicitly to a QString. Apparently that fucks up encoding everytime. We
> had to fix that at like four different places, always replacing the
> implicit stuff with QString::fromUtf8(...).
>
> Now a friend of mine told me that there are:
>
> -DQT_NO_CAST_FROM_ASCII
> -DQT_ASCII_CAST_WARNINGS
> -DQT_NO_CAST_TO_ASCII
>
> Could/should we use those? It would show these kind of errors much earlier.
Those are impractical since they (of course) also forbid the ctor for
simple c-char arrays which are used quite a lot (without any harm). of
course we could use QLatinString but I doubt the huge change would
justify the small gain. What do you think?
> Too bad we can't mark functions/methods explicit :-/
We could also supply functions which accept a QByteArray and just calls
the parent function with QString::fromUtf8(input)... That would be
failsafe... But imo a bit ugly to have that for every function...
--
Milian Wolff
http://milianw.de
More information about the KDevelop-devel
mailing list