[fxruby-users] Unicode support in FXRuby 1.6

olivers at mondrian-ide.com olivers at mondrian-ide.com
Fri Sep 2 19:50:51 EDT 2005

Did you get any information on this?  I decided to look around a bit since
I had to learn a bit of Unicode for work the other day.  I didn't find out
much, but here it is in the interest of getting a discussion going:

require 'jcode' # japanese character support module

$KCODE = 'u' # tells ruby to use the UTF-8 character set

utf_string = "\xc2\xa9" # UTF-8 code for the copyright sign

utf_string.length # -> 2, just a byte count
utf_string.jlength # -> 1, the number of UTF-8 characters

That's all I could get to happen.  So you can store Unicode strings with
the '\x' escape code, but you have to type in the UTF or Japanese encoded
bytes manually (no u'Unicode String' like in Python) and ruby doesn't
really know the difference.  There are some string utilities in the jcode
module, and jcode also alludes to a PATTERN_UTF8 option which allows you
to use Regexps with Unicode but it wasn't defined for me.  There is also
an 'iconv' module which allows you to convert between character sets, but
it is just a wrapper around a unix utility and is not available for me on
Windows XP.


> All,
> As some of you know, Jeroen has added support for Unicode strings in
> the unstable development version of FOX (version 1.5). I'm trying to
> plan ahead to decide how best to support this for FXRuby 1.6, but I
> don't really know anything about Ruby's support for Unicode or i18n in
> general. If you're familiar with this topic (how/if Ruby deals with
> Unicode strings) I'd appreciate some pointers.
> Thanks,
> Lyle
> _______________________________________________
> fxruby-users mailing list
> fxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/fxruby-users

More information about the fxruby-users mailing list