[fxruby-users] [Foxgui-users] Troubles with FXTextField encoding

Damián M. González gonzalezdamianm at hotmail.com
Sat Feb 16 12:58:14 UTC 2013


 Hi Lars, thanks for answer, I understand the facts.
 I've tried before the solution you propose without success, Ruby raises an error when you try to convert(encode(Encoding::UTF_8)), or point(force_encoding(Encoding::UTF_8)) ascii-8bit to UTF-8 for some reason.
 Now I've tried the pre-release of the 1.6.26 and works as a love, this problem was scaring me but not anymore.
 For what I know the FONTENCODING_DEFAULT setted by default for all the Fonts points to FONTENCODING_UNICODE, in words are the same, no necessity to change it for me in anywhere.
 I use every Ruby file with #encoding: utf-8 up above. Thank you so much for resolve this and to JVZ for respond the call.
 Regards. Damián-IgorJorobus.

Date: Sat, 16 Feb 2013 10:03:59 +0100
From: lars at greiz-reinsdorf.de
To: fxruby-users at rubyforge.org
CC: gonzalezdamianm at hotmail.com; foxgui-users at lists.sourceforge.net
Subject: Re: [fxruby-users] [Foxgui-users] Troubles with FXTextField encoding


  
    
  
  
    Hi Damián,

      

      sorry for responding so late. It is a spare time project for me
      and I don't know the fox toolkit that good, so I'll have to try
      things out or look at the sources. Moreover I'm quite lazy in
      answering user questions, generally.

      

      Regarding your string encoding issue: FXRuby uses UTF-8 encoding
      for all text strings since version 1.6.0. However the strings were
      not properly marked as UTF-8 in Ruby-1.9. That is obviously a bug.
      You could set the encoding of a string by hand per
      String#force_encoding('UTF-8').

      

      Please try out the new fxruby version 1.6.26.pre1 I just released.
      It should now properly return UTF-8 strings for all text returning
      methods.

      

      Some advices for unicode handling in fxruby: You should not use
      any encodings but UTF-8 when interacting with fxruby. FXRuby will
      not check or convert other encodings but will consider everything
      as UTF-8. You moreover should mark all your *.rb files with a
      header line like this:

      

      # encoding: utf-8

      

      Then even Chinese characters should be no problem. There are also
      some test cases in the test suite of fxruby for unicode handling.

      

      Regarding the font encoding: I guess
      
      
      FONTENCODING_UNICODE
      should be the suitable encoding for FXFont, but I didn't tried it
      out.

      

      Hope that helps.

      

      Regards,

      Lars

      

      

      Am 15.02.2013 03:32, schrieb Damián M. González:

    
    
      
      > > Hello Jeroen, people. I'm having troubles
        with the encoding. First of all, I'll tell you that in the app
        that am developing am using ñüáéíóú characters. I've realized
        that when the user write some of those characters and the app
        take it for work with it, later I come with troubles, that's
        because the string taked from the #FXTextField has ascii-8bit
        encoding, and as you can see here:
        http://www.sciencebuddies.org/science-fair-projects/project_ideas/CompSci_ASCII_Table.shtml
        the characters ñüáéíóú doesn't exist. So I've tried to change
        the encoding of the #FXTextField to UTF-8 but I didn't found the
        right Constant: http://rubydoc.info/gems/fxruby/frames , am I
        missing it? is somewhere hidding? nevermind. This is a little
        worse: I've tried to change the encoding as I said to another
        one, not UTF-8(because I didn't find it) but to CP850, so I did
        something like this:

        > > #...tf = FXTextField.new(parent, 10)tf.font=(app,
          FXFont.new(app, "Segoe
          UI,90,normal,5,0,#{FONTENCODING_CP850},0"))#checking the
          encoding..puts tf.encoding#=> 850

          > > Seems to work, but it doesn't. When I enter text in
          the #FXTextField, press enter and ask for the encoding,
          ascii-8bit appears, not cp850...

          > > tf.connect(SEL_COMMAND) do |sender, selector, data|
          puts data.encoding #=> <Encoding:ASCII-8BIT>end

          > > So I really don't know what happen when the user
          enter any of ñüáéíóú,... I'm getting strange errors when I
          handle those writed strings. Do any of you have some advice
          about this? will be thankfull to hear them. Is this a bug?
          Thanks for your time.

          > > P.D.: By the way I'm using FXRuby 1.6.25, Windows 7
          Proffesional 64 bits, Ruby 1.9.3p327 (2012-11-10)
          [i386-mingw32]. 

          > 

          > I can't speak for Ruby, but FOX should support UTF-8.

          > 

          > For all this to work, ensure that your FOX library is
          compiled with -DUNICODE=1

          > otherwise the interface to Win32 won't support unicode.

          > 

          > 

          > 

          > 

          > 

          > 

          > -- JVZ

          > 

          > 

          > 

          >
+----------------------------------------------------------------------------+

          > | Copyright (C) 09:10 02/14/2013 Jeroen van der Zijp. All
          Rights Reserved. |

          >
+----------------------------------------------------------------------------+

        
        

        
         Thank you Jeroen for answer. Sadly seems that there's no
          maintainer of the framework for Ruby, and I don't know how to
          check if the gem we(the users of Ruby) download is compiled
          with -DUNICODE=1, Ruby is my
            first language and I'm kind of noob related to C++.  I'm in middle of a project, hope to get some answer about if
            FXRuby is compiled with that option, if not if it can be
            fixed, etc. Does anybody knows that?
      
      

      
      

      _______________________________________________
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/20130216/b0f6f6fe/attachment-0001.html>


More information about the fxruby-users mailing list