[fxruby-users] FXRuby and Unicode

Gonzalo Garramuno ggarra at advancedsl.com.ar
Sun Oct 15 06:04:37 EDT 2006

Philippe Lang escribió:
> Hi,
> 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?

You can do just that.  Make sure you use a modern editor that saves out
Unicode UTF-8 text files (notepad, emacs, etc), not iso-8859-1 (Western
encoding) text files.

Alternatively, use the iconv.so module, like, passing the result of utf8
strings over to fxruby:

#!/bin/env ruby

require 'iconv'

class String
  # Take text from iso-8859-1 to utf-8
  @@utf = Iconv.new( 'utf-8', 'iso-8859-1' )
  # Take text from Unicode utf-8 to iso-8859-1
  @@iso = Iconv.new( 'iso-8859-1', 'utf-8' )

  def from_utf8
    @@iso.iconv( self )

  def to_utf8
    @@utf.iconv( self )

text = 'Voici est un exemple français avec iso-8859-1'
puts text

puts 'Le même texte avec utf-8:'
puts text.to_utf8

More information about the fxruby-users mailing list