Answer the question
In order to leave comments, you need to log in
How to generate CSV with required encoding in RoR?
There is a controller in UTF-8
encoding. It is required to generate a CSV in cp1251 encoding. After generating and opening the file in Excel Windows, the encoding is confused and unreadable.
CHYADNT or where to dig?
# coding: utf-8
def generate_csv(csv_file_name)
data = CSV.generate do |csv|
csv << [['Тест','Тест1'].join(';')]
csv << [['1','2'].join(';')]
end
send_data data,
type => 'text/csv; charset=windows-1251; header=present',
disposition => "attachment; filename=#{csv_file_name}"
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question