Qt-interest Archive, January 2005
Qt Application and UTF-8
Message 1 in thread
- Subject: Qt Application and UTF-8
- From: Sean Kelley <sean.sweng.projects@xxxxxxxxx>
- Date: Sun, 2 Jan 2005 22:06:29 -0600
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=KbOtGMIBKNmHZ8ST/PbfThPj+8V9v8eTcd1weVMDz9mqDlQaszvsDrvxIxv66pzYHR2rC84fcFVVJzLwCJzrmrZb5e/F5PeA8cLHuSM+c78jq0VIoN5H9eLGCYvmCXhKO95ZgJU730VNEGvTNqU62upeK86XdqpBzLGck8GUaYo=
- Reply-to: Sean Kelley <sean.sweng.projects@xxxxxxxxx>
- To: qt-interest@xxxxxxxxxxxxx
Hi,
I have a Qt application that I wrote using KDevelop. My Fedora Core 3
language is set to UTF-8:
[svk@smaointe irishprepositions]$ echo $LANG
en_US.UTF-8
In my program, I have a table of Irish prepositions that I entered
using dead keys:
u + ' = ú for example
const QString ppTable[15][7] = {
{ "agam", "agat", "aige", "aici", "againn", "agaibh", "acu" },
{ "orm", "ort", "air", "uirthi", "orainn", "oraibh", "orthu" },
{ "asam", "asat", "as", "aisti", "asainn", "asaibh", "astu" },
{ "chugam", "chugat", "chuici", "chugainn", "chugaibh", "chucu" },
{ "díom", "díot", "de", "di", "dínn", "díbh", "díobh" },
{ "dom", "duit", "dó", "di", "dúinn", "daoibh", "dóibh" },
... etc
When I run the program, I noticed that my accented characters no
longer match what I entered in the code:
For example: Instead of seeing "dúinn" displayed in my QtLineEdit
widget I see "dúinn". I display the text using the member function
setText:
lineBox->setText(ppTable[prepBox->currentItem()][pronounBox->currentItem()]);
Any help on resolving my problem with UTF-8 would be greatly appreciated.
Thanks,
Sean
Message 2 in thread
On 02.Jan 2005 - 22:06:29, Sean Kelley wrote:
> For example: Instead of seeing "dúinn" displayed in my QtLineEdit
> widget I see "dúinn". I display the text using the member function
> setText:
>
> lineBox->setText(ppTable[prepBox->currentItem()][pronounBox->currentItem()]);
QString assumes latin1 as encoding if you create a QString implictly.
Use QString::fromLocal8Bit or QString::fromUtf8 to create the String
for setText. Or store QStrings in your array.
Andreas
--
[ signature omitted ]
Message 3 in thread
- Subject: Re: Qt Application and UTF-8
- From: Sean Kelley <sean.sweng.projects@xxxxxxxxx>
- Date: Mon, 3 Jan 2005 06:33:20 -0600
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=HOV4nOElxeD36d4qpfYzTvXOI6WJWKtDclAcklechVcP55+KD+dQLtvnANNmlVkopqH4Zs53MF0e1eGKyeci+c6QXtVtUOIW9deQfllDQWurzOi43L4xH7ePU/Tgkqd0pcpz/hGS/ynHOm62ZPvDT3R/9oFra6PDaV+sSJl+vDA=
- Reply-to: Sean Kelley <sean.sweng.projects@xxxxxxxxx>
- To: qt-interest@xxxxxxxxxxxxx
Many thanks for your help. That fixed my problem.
Sean
On Mon, 3 Jan 2005 13:19:53 +0100, Andreas Pakulat <apaku@xxxxxx> wrote:
> On 02.Jan 2005 - 22:06:29, Sean Kelley wrote:
> > For example: Instead of seeing "dúinn" displayed in my QtLineEdit
> > widget I see "dúinn". I display the text using the member function
> > setText:
> >
> > lineBox->setText(ppTable[prepBox->currentItem()][pronounBox->currentItem()]);
>
> QString assumes latin1 as encoding if you create a QString implictly.
> Use QString::fromLocal8Bit or QString::fromUtf8 to create the String
> for setText. Or store QStrings in your array.
>
> Andreas
>
> --
> This will be a memorable month -- no matter how hard you try to forget it.
>
> --
> List archive and information: http://lists.trolltech.com/qt-interest/
>