Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, January 2005
Qt Application and UTF-8


Message 1 in thread

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

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/
>