Sha256: 92eeeaa9c8ee38e96ec72501128055f048322302b6eddad2464b2f0f09f4f7c7

Contents?: true

Size: 786 Bytes

Versions: 111

Compression:

Stored size: 786 Bytes

Contents

#!/usr/bin/env ruby

require 'fox16'
require 'jcode'

$KCODE = 'UTF8'

class UString < String
  # Show u-prefix as in Python
  def inspect; "u#{ super }" end

  # Count multibyte characters
  def length; self.scan(/./).length end

  # Reverse the string
  def reverse; self.scan(/./).reverse.join end
end

module Kernel
  def u( str )
    UString.new str.gsub(/U\+([0-9a-fA-F]{4,4})/u){["#$1".hex ].pack('U*')}
  end
end

include Fox

# Pass UTF-8 encoded Unicode strings to FXRuby.
label = u"Les enfants vont U+00E0 l'U+00E9cole.\nLa boulangU+00E8re vend-elle le pain en aoU+00FBt?"

FXApp.new("Unicode Example", "FoxTest") do |app|
  main = FXMainWindow.new(app, "Unicode Text", nil, nil, DECOR_ALL)
  FXLabel.new(main, label)
  app.create
  main.show(PLACEMENT_SCREEN)
  app.run
end

Version data entries

111 entries across 111 versions & 2 rubygems

Version Path
fxruby-1.6.40-x86-mingw32 examples/unicode.rb
fxruby-1.6.40-x64-mingw32 examples/unicode.rb
fxruby-1.6.40 examples/unicode.rb
fxruby-1.6.39 examples/unicode.rb
fxruby-1.6.39-x64-mingw32 examples/unicode.rb
fxruby-1.6.39-x86-mingw32 examples/unicode.rb
fxruby-1.6.38 examples/unicode.rb
fxruby-1.6.38-x64-mingw32 examples/unicode.rb
fxruby-1.6.38-x86-mingw32 examples/unicode.rb
fxruby-1.6.38.pre1 examples/unicode.rb
fxruby-1.6.37 examples/unicode.rb
fxruby-1.6.37-x64-mingw32 examples/unicode.rb
fxruby-1.6.37-x86-mingw32 examples/unicode.rb
fxruby-1.6.37.rc1 examples/unicode.rb
fxruby-1.6.37.rc1-x64-mingw32 examples/unicode.rb
fxruby-1.6.37.rc1-x86-mingw32 examples/unicode.rb
fxruby-1.6.36 examples/unicode.rb
fxruby-1.6.36-x64-mingw32 examples/unicode.rb
fxruby-1.6.36-x86-mingw32 examples/unicode.rb
fxruby-1.6.35-x86-mingw32 examples/unicode.rb