[fxruby-users] Troubles with FXTextField encoding

Damián M. González gonzalezdamianm at hotmail.com
Thu Feb 14 12:09:32 UTC 2013


 Perhaps if anybody can respond me again this old question I can solution this problem:
ashraf01 wrote Oct 09, 2007; 11:54am
 How could I take unicode characters(Chinese, Japanese etc) as Input using FXTextField.I am using WindowsXp & also setting Language options from the control panel.I am very new in this environment. Could anybody help plz..........
the only response was:
At the moment i doubt this is not possible. FOX does not support the input methods API at the moment.
 It is solved now?
 Here is a little refresh of the problem: If I generate strings inside the source code it gets the utf-8 encoding as expected, but at the moment of re-assing a string to a variable doing it by the user in a #FXTextField, the string becomes one with ascii-8bit encoding. So this is a big trouble for me because Windows use CP1252 encoding in their box titles and Ruby raises an error when I try to convert ascii-8bit into CP1252, even if I try to convert it into utf-8 encoding. If I try to show up the string as it is now(with ascii-8bit encoding) in a title in a #FXDialogBox I get strange characters. The fact is I don't know how the encoding works in the internals of Fox, how the encoding works in an #FXTextField. There are rare things, for example: entering "Á" in a FXTextField, that value will be showed in a cell in a #FXTable, it shows it correctly "Á", when I show up that string in a title of a FXDialoBox I get strange characters, not "Á"; entering "Á" in a #FXTextField, that value will be showed as an item in a #FXListBox and a #FXLabel, in both it shows "á", is not the same, it's downcased. So that's why I can't comprhend the problem, is a strange behaviour.
 The solution?
 Meaby establish UTF-8 as encoding of any text typed in a #FXTextField, but I don't know how. I didn't found documentation about it. Meaby I can find another solution if knows how the internals works about the encoding.
 Thanks for your time, I'll will appreciate your help.From: gonzalezdamianm at hotmail.com
To: fxruby-users at rubyforge.org; foxgui-users at lists.sourceforge.net
Subject: RE: Troubles with FXTextField encoding
Date: Thu, 14 Feb 2013 08:39:40 -0300





 Does anybody can help me with this? Thank you guys.
From: gonzalezdamianm at hotmail.com
To: fxruby-users at rubyforge.org; foxgui-users at lists.sourceforge.net
Subject: Troubles with FXTextField encoding
Date: Sat, 19 Jan 2013 19:00:12 -0300





 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]. 		 	   		   		 	   		   		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20130214/76cda586/attachment-0001.html>


More information about the fxruby-users mailing list