UTF8 in window title on KDE

Hello,

I have a Motif application, which I have recently "upgraded" to use antialiased fonts (with XFT) and UTF-8 encoding, as OpenMotif 2.3 enables me to do this.
Everything works fine, just the window and dialog titles are displayed incorrectly, they use iso8859-1 encoding. So it works OK for English,
but not so well for other languages with characters >128.
I am using KDE on SUSE 10.3

To set the window title, I set the string with XmNdialogTitle resource.
In the old days, there was no need to tell the encoding of the
Widget's window title. So I guess Motif lacks a way to tell the
character encoding for the title. Is there something I do not know about Motif, or is there a way to set window title from Xt or X?

Other programs like Firefox have no problem displaying window
title with various national characters.

Thank you for your help,

Dušan Peterc
http://www.arahne.si


Andriy Konoval

Andriy Konoval's picture

Re: UTF8 in window title on KDE

It seems to me that the issue isn't connected with Motif. I believe that you try to set UTF-8 title in non-UTF-8 environment. Please make sure that your LC_ALL and LANG specifies UTF-8 locale.


dpeterc

dpeterc's picture

Re: UTF8 in window title on KDE

Thanks for your help, Andriy,

It is a little more complex - it s acutally quite "legal" to run iso-8859-x encoded application,
for example "legacy motif" program in a UTF-8 enabled environment like KDE or Gnome.
And still we want the window title to display properly.

In the mean time I figured out how to do this, so I share my code
in case somebody else has this problem.
It needs to be done at X Window level and requires interaction with window manager.
Currently, this can not be done with Motif functions.

#define _NET_WM_NAME 0
#define UTF8_STRING 1

static Atom atoms[2];
static char *atom_names[] =
{
"_NET_WM_NAME",
"UTF8_STRING",
};

/* need to do do this only the first time */
XInternAtoms(display, atom_names, 3, FALSE, atoms);
XChangeProperty(display, window, atoms[_NET_WM_NAME], atoms[UTF8_STRING], 8, PropModeReplace, (unsigned char *) title, strlen(title));


dpeterc

dpeterc's picture

Re: UTF8 in window title on KDE

... one typo in the previous post, so I repeat the code ...

#define _NET_WM_NAME 0
#define UTF8_STRING 1

static Atom atoms[2];
static char *atom_names[] =
{
"_NET_WM_NAME",
"UTF8_STRING",
};

/* need to do do this only the first time */
XInternAtoms(display, atom_names, 2, FALSE, atoms);
XChangeProperty(display, window, atoms[_NET_WM_NAME], atoms[UTF8_STRING], 8, PropModeReplace, (unsigned char *) title, strlen(title));