[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Encoding in ruby/tk internals

Nikolay Ponomarenko

11/19/2003 8:39:00 AM

Hello ruby-talk peoples,

It seems that something is wrong in ruby/tk libraries:

I'm trying to work with cp1251 encoding. Everything works fine, until
i try to use "percent substitutions" - params values are passed in
unicode, ignoring Tk.encoding value.

In pure Tcl all works normal -

encoding system "cp1251"
-command [list tblCmd $table(array) %i %C %s]

%s value is passing to tblCmd in cp1251
but when i try to do something like that in ruby

Tk.encoding = 'CP1251'
@entry = TkEntry.new
@entry.configure('validatecommand',[proc {|s| v(s)},'%s'])

%s is passing to v in utf-8 :(

Such behavior is bug, feature or i'm doing something wrong?
It there any way to retrive "percent substitutions" values in correct
encoding?

--
Best regards,
Nikolay



7 Answers

Hidetoshi NAGAI

11/19/2003 9:23:00 AM

0

Nikolay Ponomarenko

11/20/2003 6:59:00 AM

0

Hello Hidetoshi,

Wednesday, November 19, 2003, 11:23:19 AM, you wrote:

>> In pure Tcl all works normal -
>> encoding system "cp1251"
>> -command [list tblCmd $table(array) %i %C %s]
>>
>> %s value is passing to tblCmd in cp1251
>> but when i try to do something like that in ruby
>>
>> Tk.encoding = 'CP1251'
>> @entry = TkEntry.new
>> @entry.configure('validatecommand',[proc {|s| v(s)},'%s'])
>>
>> %s is passing to v in utf-8 :(

HN> After calling Tk.encoding_system = 'cp1251',
HN> do you get the same result?

Yes.
something like

Tk.encoding_system = 'cp1251' # or Tk.encoding = 'cp1251'
$btn = TkButton.new($root) {
text "and here text in cp1251"
}
works right

Problem is only with "%" values :(




--
Best regards,
Nikolay



Hidetoshi NAGAI

11/20/2003 8:44:00 AM

0

Nikolay Ponomarenko

11/20/2003 9:26:00 AM

0

Hello Hidetoshi,

Thursday, November 20, 2003, 10:44:10 AM, you wrote:

HN> Tk.encoding_convertto(TkComm::string(arg_val[idx]), enc)

Seems that something wrong here.

I try to replace it with this for testing and debug purpose

puts Tk.encoding_convertto(TkComm::string(arg_val[idx]), enc)
puts Iconv.iconv('CP1251','UTF-8',TkComm::string(arg_val[idx]))
arg_cnv << Iconv.iconv('CP1251','UTF-8',TkComm::string(arg_val[idx]))

works right

--
Best regards,
Nikolay



Hidetoshi NAGAI

11/20/2003 5:04:00 PM

0

Nikolay Ponomarenko

11/21/2003 7:21:00 AM

0

Hello, Hidetoshi!
You wrote on Fri, 21 Nov 2003 02:04:10 +0900:

??>> I try to replace it with this for testing and debug purpose
??>>
??>> puts Tk.encoding_convertto(TkComm::string(arg_val[idx]), enc)
??>> puts Iconv.iconv('CP1251','UTF-8',TkComm::string(arg_val[idx]))
??>> arg_cnv << Iconv.iconv('CP1251','UTF-8',TkComm::string(arg_val[idx]))
??>>
??>> works right

HN> Hmmm...
HN> Could you try to replace
HN> 'Tk.encoding_convertto(TkComm::string(arg_val[idx]), enc)'
HN> to 'Tk.fromUTF8(TkComm::string(arg_val[idx]), enc)'?

Works right. Thanks a lot. Will this fix became official?

HN> # Is the value of enc is 'cp1251'?

Yes, of course.

By the way, why such functions as
Tk.encoding_convertto
Tk.fromUTF8

are not described anywhere?

With best regards,
Nikolay Ponomarenko.

Hidetoshi NAGAI

11/21/2003 7:41:00 AM

0