[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: local8Bit
From:       Henrik Johnson <hpj () globecom ! net>
Date:       2001-05-30 8:27:11
[Download RAW message or body]

> Hi!

> I just figured local8Bit is fixed to what Qt figures from $LANG. Klocale 
sets
> the codec to the one used by KDE, but as local8Bit uses a static object 
the
> first call counts and that's in:

> #0  QString::local8Bit (this=0xbffff5bc) at tools/qstring.cpp:14452
> #1  0x40751c74 in locale_encoder (fileName=@0xbffff5bc) at 
tools/qfile.cpp:466
> #2  0x40751cac in QFile::encodeName (fileName=@0xbffff5bc)
>     at tools/qfile.cpp:496
> #3  0x4074398b in QFile::open (this=0xbffff5ac, m=1)
>     at tools/qfile_unix.cpp:212
> #4  0x4078b1a8 in qt_init_internal (argcptr=0x405b62f0, argv=0xbffff88c,
>     display=0x0) at kernel/qapplication_x11.cpp:1253
> #5  0x4078bd75 in qt_init (argcptr=0x405b62f0, argv=0xbffff88c)
>     at kernel/qapplication_x11.cpp:1489

> So I see not many chances.
> 1. create KLocale::local8Bit() which does the right thing and overwrite
>    locale_encoder using that function
> 2. set LANG _before_ QApplication() is called, but the only code that 
runs in
>     typical KDE applications before the KApp constructor is 
KCmdlineoptions
>    and using that sounds wrong.

> Any other options? The way it's now makes local8Bit useless and as this 
KDE
> in russian useless unless you set LANG to the value used in kcontrol 
before
> you start KDE.

Not having checked the source I think this line can solve it.

Qapp->setDefaultCodec(QTextCodec::codecForName(getenv("LANG")));

Where the QtextCodec stuff is replaced with whatever codec you actually 
use. I use this in an application and I know I get the desired result and 
before having it it didn't work. Don't really know why it doesn't get the 
codec from LANG itself, but hey. I stick with what works :).

/Mauritz
GlobeCom AB

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic