[fxruby-users] FXRuby and Unicode

Lyle Johnson lyle at knology.net
Sun Oct 15 08:54:05 EDT 2006

On Oct 15, 2006, at 2:48 AM, Philippe Lang wrote:

> It works fine, thanks. But instead of this program, wouldn't it be  
> possible to write a program where your include the accents directly  
> in the source coude, just like with other languages?

Jeroen will hopefully correct me if I'm wrong on this, but FOX can't  
just guess how a string (with some accented characters) is encoded.  
For that reason, FOX only directly accepts UTF-8 encoded Unicode  

In the program you attached to your message (where you included the  
accents directly in the source code), the string "looks" correct when  
I see it in my Mail program. But I don't know how those accented  
characters were originally encoded.

If they are UTF-8 encoded in the version you're trying to run on your  
computer, then yes, that should work properly. For that to be true,  
the "à", which is Unicode U+00E0, would need to appear as the bytes  
(C3, A0). That's how that character is encoded in UTF-8.

If on the other hand, the characters are encoded in the ISO Latin 1  
character set (a.k.a. ISO 8859-1) -- which is a distinct possibility,  
as a lot of editors use that by default -- your "à" character is  
probably encoded using the single byte E0. That single byte doesn't  
make any sense in UTF-8 encoding, and that why you'd see a square (or  
some other error character) in a program that was trying to decode it  
as if it were UTF-8.

So the question is, what to do if you have strings encoded in some  
format other than UTF-8? I think we might be able to use Ruby's Iconv  
library for this. FOX also has a number of codecs that I have not yet  
exposed in FXRuby, but those might be good candidates too...

More information about the fxruby-users mailing list