# CVS from Excel Encoding issue

**URL:** <https://www.ruby-forum.com/t/cvs-from-excel-encoding-issue/184066>\
**Category:** Rails\
**Created:** [February 24, 2010, 2:49pm UTC](https://www.ruby-forum.com/t/cvs-from-excel-encoding-issue/184066 "2010-02-24T14:49:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![homerlex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/bcef8e/32.png) [@homerlex](https://www.ruby-forum.com/u/homerlex)\
**Post date:** [February 24, 2010, 2:49pm UTC](https://www.ruby-forum.com/t/cvs-from-excel-encoding-issue/184066/1 "2010-02-24T14:49:00Z")

</div>

Sorry for the cross post but no takers in the Ruby forum:

Using Ruby 1.8 (for Rails 2.3.5)

I have a cvs file that was exported from an Excel file.

Some of the text contains characters like â€œTest in quotesâ€ (I think  
these are smart quotes)

I can properly change this to UTF-8 via:

Iconv.conv(“utf-8”, “cp1251”, text)

Other text contains text like spanish characters like SeÃ±ora. I can  
properly change this to UTF-8 like this:

Iconv.conv(“utf-8”, “iso-8859-1”, text)

However I cannot figure out how to get some text that has both types of  
characters like this:

â€œTest in quotesâ€ SeÃ±ora

If I don’t get these properly into utf-8 they do not persist properly in  
mysql (they appear as ?)

Any ideas? Any help is greatly appreciated.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![homerlex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/bcef8e/32.png) [@homerlex](https://www.ruby-forum.com/u/homerlex)\
**Post date:** [February 25, 2010, 9:37pm UTC](https://www.ruby-forum.com/t/cvs-from-excel-encoding-issue/184066/2 "2010-02-25T21:37:39Z")

</div>

Bump - anyone?

---

<div class="post-metadata">

**Author:** ![homerlex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/bcef8e/32.png) [@homerlex](https://www.ruby-forum.com/u/homerlex)\
**Post date:** [February 26, 2010, 5:20pm UTC](https://www.ruby-forum.com/t/cvs-from-excel-encoding-issue/184066/3 "2010-02-26T17:20:20Z")

</div>

On Feb 24, 8:49 am, Homer S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> “Test in quotes” Señora
> 
> If I don’t get these properly into utf-8 they do not persist properly in  
> mysql (they appear as ?)

You may want to try converting from Windows-1252 (not 1251), as the  
“smart quotes” are the same codepoints in both, but 1252 has the  
Spanish characters rather than the Cyrillic characters found in 1251.

–Matt J.

---

<div class="post-metadata">

**Author:** ![homerlex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/bcef8e/32.png) [@homerlex](https://www.ruby-forum.com/u/homerlex)\
**Post date:** [February 26, 2010, 5:29pm UTC](https://www.ruby-forum.com/t/cvs-from-excel-encoding-issue/184066/4 "2010-02-26T17:29:01Z")

</div>

Matt J. wrote:

> On Feb 24, 8:49ï¿½am, Homer S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > ï¿½Test in quotesï¿½ Seï¿½ora
> > 
> > If I don’t get these properly into utf-8 they do not persist properly in  
> > mysql (they appear as ?)
> 
> You may want to try converting from Windows-1252 (not 1251), as the  
> “smart quotes” are the same codepoints in both, but 1252 has the  
> Spanish characters rather than the Cyrillic characters found in 1251.
> 
> –Matt J.

Thanks Matt! You are my hero 🙂
