[fxruby-users] FXRuby1.6.5 ?

Ernest Ellingson erne at powernav.com
Wed Feb 7 10:12:03 EST 2007

Here's the direct reference to my code.


I know this is code for converting a file, but constructing a utf8 
string from unicode is straight forward in the code.

If his problem is a simple Lyle describes.  Then do this
look up the character in the character set.


Find the decimal value for the character.

c=[decimal value of character].pack('U')

for example
the decimal value for CYRILLIC CAPITAL LETTER IO is 161  in iso8859-5  
(a one byte representation of the character)
In order to get the utf-8 representation  you have to convert the one 
byte representation to a two or more byte representation based on the 
utf-8 rules.
Ruby does this with array.pack

c=[161].pack('U")   => "\302\241"

The result is the octal values for the two bytes required in this case.

That's all he has to do.

Lyle Johnson wrote:
> On Feb 6, 2007, at 10:09 PM, Ernest Ellingson wrote:
>>     This might help you.
>> It's a message from me in Dec. 2001 to the ruby-talk forumn
>> http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb?key=unicode&cginame=namazu.rb&submit=Search&dbname=ruby-talk&max=50&whence=0
>> You should be able to convert unicode to utf8 using the code snippet 
>> there.  REXML incorporates that code into its parsers.
> Thanks, Ernie, but I believe the problem that Aleksey is dealing with 
> is that he has (literal) strings in ISO-8859-5 (Latin/Cyrillic) 
> encoding, and he's wanting to pass those directly into FXRuby (e.g. as 
> the label for a button). However, as best I understand it, FOX expects 
> those strings to be UTF-8 encoded Unicode, so Aleksey needs to do 
> something to convert his ISO-8859-5-encoded strings into UTF-8 encoded 
> Unicode, e.g.
> require 'iconv'
> button = FXButton.new(p, Iconv.new("iso-8859-8", 
> "utf-8").iconv(original_russian_text), ...)
> -- Lyle
> ------------------------------------------------------------------------
> _______________________________________________
> fxruby-users mailing list
> fxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/fxruby-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20070207/8d6feb5e/attachment.html 

More information about the fxruby-users mailing list