How to convert string from utf8 to current locale? - Xwindows
This is a discussion on How to convert string from utf8 to current locale? - Xwindows ; Hi, All
I fill from XA_PRIMARY XTextProperty member 'value' as utf8 string (I've
checked it by converting with iconv into koi8-r, so I'm sure that it is
really utf8).
Thus, I need to convert that member to current locale (in ...
-
How to convert string from utf8 to current locale?
Hi, All
I fill from XA_PRIMARY XTextProperty member 'value' as utf8 string (I've
checked it by converting with iconv into koi8-r, so I'm sure that it is
really utf8).
Thus, I need to convert that member to current locale (in my case in
ru_RU.KOI8-R). I've tested Xutf8TextPropertyToTextList() but it returns
unchanged string...
What can you advise to me? (I don't need to draw string in a window, for
example, by Xutf8DrawImageString(), so such answer is useless)
-Alex'a X Spirit-
-
Re: How to convert string from utf8 to current locale?
In comp.windows.x, Alex'a X Spirit
wrote
on Sat, 17 Jul 2004 21:29:05 +0300
:
> Hi, All
>
> I fill from XA_PRIMARY XTextProperty member 'value' as utf8 string (I've
> checked it by converting with iconv into koi8-r, so I'm sure that it is
> really utf8).
>
> Thus, I need to convert that member to current locale (in my case in
> ru_RU.KOI8-R). I've tested Xutf8TextPropertyToTextList() but it returns
> unchanged string...
>
> What can you advise to me? (I don't need to draw string in a window, for
> example, by Xutf8DrawImageString(), so such answer is useless)
>
> -Alex'a X Spirit-
>
Well, the obvious questions first.
[1] LANG=ru_RU.KOI8-R; export LANG
although I'm not 100% sure of this. (I'm a LANG=C person, if that. :-) )
[2] Does XSupportsLocale() return False? (Probably not,
since you're getting a copy of the string back. Might
be useful to just check, though.)
[3] The Xutf8TextPropertyToTextList() takes as its 4th parameter
an XICCEncodingStyle, which can be one of the following:
XStringStyle: either STRING or COMPOUND_TEXT items are returned.
XUTF8StringStyle: UTF8_STRING items are returned. (This is
an XFree86 extension; check for the macro X_HAVE_UTF8_STRING.)
XTextStyle: The encoding is the current locale. This is probably
what you want.
XStdICCTextStyle: STRING if the text is fully convertible to STRING,
otherwise COMPOUND_TEXT. (My manpage isn't all that clear
on why this is different from XStringStyle, and I've not tried
this stuff myself.)
--
#191, ewill3@earthlink.net
It's still legal to go .sigless.
-
Re: How to convert string from utf8 to current locale?
On Sun, 18 Jul 2004 04:01:01 GMT, The Ghost In The Machine wrote:
> In comp.windows.x, Alex'a X Spirit
>
> wrote
> on Sat, 17 Jul 2004 21:29:05 +0300
> :
>> I fill from XA_PRIMARY XTextProperty member 'value' as utf8 string
>> (I've checked it by converting with iconv into koi8-r, so I'm sure
>> that it is really utf8).
>>
>> Thus, I need to convert that member to current locale (in my case in
>> ru_RU.KOI8-R). I've tested Xutf8TextPropertyToTextList() but it
>> returns unchanged string...
[...]
> Well, the obvious questions first.
> [1] LANG=ru_RU.KOI8-R; export LANG
> although I'm not 100% sure of this. (I'm a LANG=C person, if that.
> :-) )
My locale is OK, the problem exactly not here
> [2] Does XSupportsLocale() return False? (Probably not,
> since you're getting a copy of the string back. Might
> be useful to just check, though.)
SupportsLocale() return True
> [3] The Xutf8TextPropertyToTextList() takes as its 4th parameter
> an XICCEncodingStyle, which can be one of the following:
No Xutf8TextPropertyToTextList() but Xutf8TextListToTextProperty() takes
XICCEncodingStyle. Any way, I've examined all variants of
ICCEncodingStyle, but nothing changes (I can convert utf8 in
COMPOUND_TEXT only)
[...]
-Alex'a X Spirit-
-
Re: How to convert string from utf8 to current locale?
Alex'a X Spirit wrote:
>Hi, All
>
>I fill from XA_PRIMARY XTextProperty member 'value' as utf8 string (I've
>checked it by converting with iconv into koi8-r, so I'm sure that it is
>really utf8).
Properties are encoded as COMPOUND_TEXT, not UTF8. Your value would
lack the escape sequence (\033%G) to flag it as such, so it would be
treated as being in your current locale.
> Thus, I need to convert that member to current locale (in my case in
> ru_RU.KOI8-R). I've tested Xutf8TextPropertyToTextList() but it
> returns unchanged string...
Yup.
> What can you advise to me? (I don't need to draw string in a
> window, for example, by Xutf8DrawImageString(), so such answer is
> useless)
Set the property with the output of Xutf8TextListToTextProperty.
The rationale for properties is to try to keep them as close to the
national language as possible (for compatablility with old programs
which have not been internationalized). Thus, if your UTF8 data is
expressible in KOI8-r (and that is the current locale), it will be
stored as such. Minimal escapes to UTF8 will be made for characters
that cannot be represented in the current locale.
>
> -Alex'a X Spirit-
>