i18n and QStrings
Simon Hausmann
hausmann at kde.org
Sat Nov 29 19:14:51 GMT 2003
On Sat, Nov 29, 2003 at 06:53:18PM +0200, Andras Mantia wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> As today I hit the problem that my QString got damaged after a i18n call (it
> contained unicode chars - eg. ?? = udoubleacute - and it was replaced by ?)
> because i18n() expects const char *, I think it would be a good idea to add a
> QString i18n(const QString& text) which would call simply be:
>
> QString i18n(const QString& text)
> {
> return i18n(text.utf8());
> }
>
> Is it a bad idea? Yeah, I don't really know which one will be picked up in
> case of i18n("foo")...
I can't really say whether such an overload is good or possibly
increases chances to produce more bugs. Off-hand I think it's a good
idea because it allows cleaning up all the existing i18n(foo.utf8())
calls. But I might easily miss something.
However I think you should add a
CXXFLAGS="$CXXFLAGS $KDE_DEFAULT_CXXFLAGS" line to your
configure.in.in , because that helps to prevent the bug you
experienced from happening in the first place, as it disables the
implicit QString -> const char * conversion using the
QT_NO_ASCII_CAST define.
Simon
More information about the kde-core-devel
mailing list