problem about read .txt file

P

Pat Kiatchaipipat

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??
:'(
 
A

Alex Young

Pat said:
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??

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

Phrogz

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)

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,271
Messages
2,571,354
Members
48,041
Latest member
Oliwen826

Latest Threads

Top