igorkasyanchuk/rails_db

Export to CSV - UTF8 encoding

Closed this issue · 2 comments

This gem is amazing, thank you so much!

I noticed one issue with the CSV export feature with special characters such as é, è, à, etc.
When I open the CSV file with Excel these special characters are not rendered correctly (é => √©, è => √®, à => √†)

May I suggest that you try to force UTF-8 encoding as such?

def csv
  send_data(@sql_query.to_csv.encode("UTF-8"), type: 'text/csv; charset=utf-8; header=present', filename: 'results.csv')
end

Thanks!

I realized that the issue was not with the exported file but with the way Excel was handling it.
Anyway, thanks a ton for this gem 💎