[Kde-bindings] Re: Text encoding in Ruby 1.8 plugins

Arno Rehn arno at arnorehn.de
Fri Feb 18 14:58:59 UTC 2011


On Tuesday 15 February 2011 20:25:57 David Palacio wrote:
> Hi,
> 
> When passing UTF8 text to Qt widgets the text appears garbled. Setting
> $KCODE='u' in the plugin code does not fix it as QtRuby might have
> already guessed how to encode Ruby strings (see init_codec() in
> handlers.cpp). And the interpreter sets $KCODE to "NONE" by default,
> so ruby strings are always treated as Latin strings. I am thinking of
> two solutions for this:
> 
> 1. Use to/fromLocal8Bit as default case when converting strings.
> 2. Let krubypluginfactory set $KCODE when -Kkcode is set in RUBYOPT
> environment variable.
> 
> I prefer 1. as my current problem does not involve utf8 strings in the
> code at all, but only user data (from a 3rd party library), that might
> be in any encoding, in any locale. fromLocal8Bit should handle this well.
> What I do not like about 2. is that it requires each user to modify
> their environment.
> 
> What do you think? Am I missing a way to set $KCODE early?
Difficult. What does KCODE being "NONE" mean? Does it mean "use ASCII" (in 
which case Local8Bit would be wrong I guess) or does it mean "use the encoding 
matching the locale"?
Maybe we should simply default to UTF-8 in krubypluginfactory. I guess that 
would make life easier.

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list