# Problem encoding from csv to mysql

**URL:** <https://www.ruby-forum.com/t/problem-encoding-from-csv-to-mysql/186290>\
**Category:** Deployment\
**Created:** [April 3, 2010, 7:52pm UTC](https://www.ruby-forum.com/t/problem-encoding-from-csv-to-mysql/186290 "2010-04-03T19:52:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![salautom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85f322/32.png) [@salautom](https://www.ruby-forum.com/u/salautom)\
**Post date:** [April 3, 2010, 7:52pm UTC](https://www.ruby-forum.com/t/problem-encoding-from-csv-to-mysql/186290/1 "2010-04-03T19:52:12Z")

</div>

Hello,

I do have a problem with encoding from a (ANSI) csv file on a Windows  
platform to a utf-8 encoded mysql table.

I get the following error: Mysql::Error: Incorrect string value:  
‘\xE9basti…’ for column ‘display\_name’ at row 1: UPDATE `users` SET  
`updated_at` = ‘2010-04-03 13:27:21’, `display_name` = ‘Sï¿½bastien’ WHERE  
`id` = 23  
the character is an Ã© (which is normal acsii code 130, but in this file  
233.

I’m reading the file with fastercsv.  
in the database the encoding is set to utf8.

I also tried some conversion with IConv like:

```
file_path = File.join(RAILS_ROOT,"import","#{file}.csv")
csv_data = Iconv.iconv('UTF-8','ASCII//TRANSLIT',file_path).to_s

```

(I tried ASCII//TRANSLIT, LATIN1, IBM367, ANSI\_X3.4-1968, ASCII, and  
more)  
It looks like the encoding isn’t doing anything.

Ruby 1.8.7, Rails 2.3.5

Regards,  
Henk.

---

<div class="post-metadata">

**Author:** ![salautom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85f322/32.png) [@salautom](https://www.ruby-forum.com/u/salautom)\
**Post date:** [April 20, 2010, 12:28pm UTC](https://www.ruby-forum.com/t/problem-encoding-from-csv-to-mysql/186290/2 "2010-04-20T12:28:03Z")

</div>

Finaly found it, I had to use ‘MS-ANSI’ to encode from

---

<div class="post-metadata">

**Author:** ![salautom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85f322/32.png) [@salautom](https://www.ruby-forum.com/u/salautom)\
**Post date:** [November 23, 2010, 10:00pm UTC](https://www.ruby-forum.com/t/problem-encoding-from-csv-to-mysql/186290/3 "2010-11-23T22:00:41Z")

</div>

Hope this may help you…  
[http://www.ronithomas.com/csv-to-mysql-converter/](http://www.ronithomas.com/csv-to-mysql-converter/)
