Problem about read .txt file

I have read text by this code

  message = ""

  file = File.new(fileDirectory , "r")
    while line = file.gets
      message = message+line
    end
  file.close
  puts message
  @textbox1.set_value(message)

fileDirectory is a path of text file
@textbox1 is textctrl that I want to show text in that file

and I have problem, it can only read text file with Encoding UTF-8, it
can’t read from ANSI to show in textctrl (@textbox1) but

puts message

can show message normally with encode UTF-8 and ANSI

now I have problem how I can show text with encode ANSI in @textbox1??
:’(

Pat K. wrote:

  @textbox1.set_value(message)

now I have problem how I can show text with encode ANSI in @textbox1??

That sounds toolkit-specific. What GUI library are you using?

Alex Y. wrote:

Pat K. wrote:

  @textbox1.set_value(message)

now I have problem how I can show text with encode ANSI in @textbox1??

That sounds toolkit-specific. What GUI library are you using?

I use wxruby :slight_smile:

On Nov 26, 3:10 am, Pat K. [email protected] wrote:

  @textbox1.set_value(message)

How is the above different or better than:
message = IO.read( fileDirectory )
?

Dont know about wxruby but in ruby-gtk you can use Glib to convert
charsets

But as someone else wrote before here, play around with iconv or similar
to convert it before displaying on your GUI

Pat K. wrote:

Alex Y. wrote:

Pat K. wrote:

  @textbox1.set_value(message)

now I have problem how I can show text with encode ANSI in @textbox1??
That sounds toolkit-specific. What GUI library are you using?

I use wxruby :slight_smile:
I don’t know anything specific about WxRuby, but have you looked at
using iconv?