Forum: wxRuby Handling Unicode in WxRuby

D296be781534c9043ec914c926352f44?d=identicon&s=25 Jamal Mazrui (Guest)
on 2011-07-19 03:23
(Received via mailing list)
If I am using Ruby 1.8.7, what are some recommended practices for
supporting Unicode within a WxRuby application?  My understanding, based
on web research, is that I should use the multibyte module of Active
Support in order to add Unicode support to Ruby 1.8.7 (Ruby 1.9 includes
Unicode support natively).

Generally, I have read the recommendation that it is best to do
everything in UTF-8.  I can try to do so, but am wondering how WxRuby
handles strings that are passed to set properties, e.g., the text of a
label.  Does this library expect strings to be in a certain encoding?
How can UTF-8 be specified to WxRuby?

Jamal
85991f138ede6236f35eb98da22b7b01?d=identicon&s=25 Marvin Gülker (quintus)
on 2011-07-19 13:39
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 19.07.2011 02:51, schrieb Jamal Mazrui:
> If I am using Ruby 1.8.7, what are some recommended practices for
> supporting Unicode within a WxRuby application?  My understanding,
> based on web research, is that I should use the multibyte module of
> Active Support in order to add Unicode support to Ruby 1.8.7 (Ruby
> 1.9 includes Unicode support natively).

I'd highly recommend using Ruby 1.9. It's much more painless.
Back in times before I switched to Ruby 1.9, I used the Iconv module
(stdlib) to convert all my strings to UTF-8. If I remember correctly, it
worked like this:

require "iconv"
ary = Iconv.iconv("UTF-8", "yoursourceencoding", "1st_string",
"2nd_string")

> Generally, I have read the recommendation that it is best to do
> everything in UTF-8.  I can try to do so, but am wondering how
> WxRuby handles strings that are passed to set properties, e.g., the
> text of a label.  Does this library expect strings to be in a certain
> encoding? How can UTF-8 be specified to WxRuby?

wxRuby expects your strings to be UTF-8-encoded, there's no way to tell
wxRuby you want to use another encoding AFAIK. wxRuby just passes the
strings directly to the underlying wxWidgets, resulting in incorrect
characters being displayed in the final GUI.

> Jamal

Vale,
Marvin

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOJVfUAAoJELh1XLHFkqhaLksH/R5Dp4YXAKWgrVvXcZRks2WV
bKn8IgtLTn5oPXRXu4Xsgazl/GhtOed4bw21GpNt6LKYbUPDvrHpVKMH9oJOaFXy
9WG4n+Gn3chUlmmh3eid6aVVRWKPLwU7HX3NJE66Y0NAFBo9bR6ch7d+9ELhHgQk
53sWabyfYPouvELGbigK/0DLmCiz/A3z0/9KqDxWAgCNcBdsiQjbQ4UWMjC+yNmT
Uc0pncrL9jWFLoJ6RddcS2RQUnmGUaLqAAozrq0hmWJ5csTrDxMAZ1hb8i4IYW7X
ngeTkPdOLNBRovHN9tqxbODHVQatfb4P7VhTi7H6g+ueqeAHDaIcOyZRIfZWZ5U=
=bOuD
-----END PGP SIGNATURE-----
This topic is locked and can not be replied to.