[jruby-user] Fwd: Fwd: utf-8 or unicode on Swing jlabel

Showing 1-5 of 5 messages
[jruby-user] Fwd: Fwd: utf-8 or unicode on Swing jlabel Manuel Ramos Caro 7/14/12 7:49 PM


 I try to print a utf-8 string into a jlabel but it's not readeable... but when i put to console all are ok... any idea of a solution ...

[jruby-user] utf-8 or unicode on Swing jlabel 2 Manuel Ramos Caro 7/18/12 5:18 PM

After a hard study of the problem i think that the better solution is convert from UTF-8 to Java Unicode escape sequence...

It's look like...

"\xC3\xB1" --conversion--> "\u00F1"

...and then past it to the Jlabel...any Jruby example for this out there...???

The idea is to convert any utf-8 char to it Java Unicode Escape value for multilingual support...

I'm migrating a Open Source GUI from Shoes to Jruby and Swing....

[jruby-user] Re: utf-8 or unicode on Swing jlabel 2 Manuel Ramos Caro 7/25/12 5:48 PM
Hi, again...

After  study and a hard work i think that i have a solution on Windows and Linux...

I write a class that's reencode the sequence on a new sequence of chars and then return it as java string... on Windows an aditional work must be done an unicode font on must be set the Jlabel...

¿Any Open source font out there?
¿Any sugestion or corrections for this class?

Manuel Ramos Caro

class UnicodeEscape
  def initialize(string)
       @string = '\\u'+ string.unpack("U*").map{|c|"%04x" %c}.join('\\u')
       puts "transformed ucode string: " + @string.to_s
       @string_out = java.lang.StringBuilder.new
       i = 0
       @string.split('\u').each do |piece|  
            if i > 0  
               puts "char " + i.to_s + " :" + piece 
               @char = java.lang.Character.new java.lang.Integer.parseInt(piece, 16).to_java(:char)
               puts "char " + i.to_s + " :" + @char.to_s
            end #if i > 0
            i += 1
       end #@string.split('\u').each do |piece|
       puts "output string: " + @string_out.toString.to_s
  end #def initialize(string)
  def return_unicode_escape
       return @string_out.toString
  end #def return_unicode_escape
end #class UnicodeEscape
Re: [jruby-user] Re: utf-8 or unicode on Swing jlabel 2 Roger Gilliar 7/26/12 12:02 PM

I did a lot of Swing programming with JRuby and never had such problems. Could you post some sample code that shows your problem ?


Am 26.07.2012 um 02:48 schrieb Manuel Ramos Caro <manuelr...@gmail.com>:

Re: [jruby-user] Re: utf-8 or unicode on Swing jlabel 2 Manuel Ramos Caro 7/26/12 2:19 PM
Thanks, the problem is solved i have tested this translation class and work for me... i must take a stream converted to UTF-8 with iconv and isn't posible to me to write a simple 'ñ' that latest Jruby puts ok on a linux console  using a Jlabel with setText source on that stream instead any usage of unicode scaped charset hardcoded work ok \\uxxxx... but after this translation i had a correct string to put on this label thats works ok... i have test it on windows and linux with chinesse chartset...and it's hard send you a complete example thats works...

This is the application...


...there's not any jruby out there i'm doing a initial transition...before commit any code on repo...

if you used a open source font that support a wide range of charset... that can help a little more.... i'm using a close one from MS on testing...

Manuel Ramos Caro.