[Kde-bindings] Re: Text encoding in Ruby 1.8 plugins
David Palacio
dpalacio at orbitalibre.org
Fri Feb 18 00:09:28 UTC 2011
On Tue, Feb 15, 2011 at 02:25:57PM -0500, 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?
>
> Regards,
>
> David
>
Testcase plasmoid. Uncompress, cd encoding, plasmoidviewer .
-------------- next part --------------
A non-text attachment was scrubbed...
Name: encoding.zip
Type: application/zip
Size: 1127 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20110217/39d3b4a1/attachment.zip>
More information about the Kde-bindings
mailing list