Thai fonts are not wriiten in csv file

Hi,

I need to upload a csv file, process and again store the values as csv
in another location.

In my csv i have thai fonts for some fields, i read it as binary and
when i tried to write again as a csv. the fonts are displayed like
‘???’. I tried to write this in txt file and it works.

What to do to fix this?

I tried with fastercsv(also tried :encoding => ‘u’ for fastercsv) it
fails so i came to core ruby to do the job for me.

I have tried to read and write the file as binary data but was not
successfuly.

My codes are,

File.open(“filename.csv”, “wb”) do |csv|

File.open("uploaded_file.csv, “rb”) do |row|

each_line = row.readlines

each_line.each do |line|

   line = line.split(',')
   new_row =[line[1],line[3],line[4],line[5],line[6]].join(',')
   csv.write(new_row)

end

end
end

Any suggestions please?

Thanks in advance

Regards,
Jose