Encoding Help!

I have this CSV upload feature on this rails site I’m working on. The
CSV file contains all kinds of French, and Italian words that are
uploaded into the DB. The problem I’m having is after the words are
uploaded, some of the characters are changes to either the little
diamond question mark thing, or the box with the 4 small digits in it,
or just another letter altogether.

The CSV is iso-8859-1. I’ve changed the database.yml to encoding:
latin1, tried running ‘alter table words charset=latin1;’ in mysql. I’ve
tried using string.force_encoding(Encoding::ISO_8859_1) when saving, and
even wrote a method in the String class
class String
def to_iso
Iconv.conv(‘ISO-8859-1’, ‘utf-8’, self)
end
end

I even have the in my layout…

So, what are the best steps to take a .CSV file that is full of
ISO-8859-1 characters, and upload it to the DB so they are displayed
exactly how they are in the file?

Bonus Question:

In case anyone knows… The CSV file is being created with Microsoft
Excel. Is there a way to save the file as UTF-8 so I can just move on
with my life? :slight_smile:

Thanks for the help,

~Jeremy

So, what are the best steps to take a .CSV file that is full of
ISO-8859-1 characters, and upload it to the DB so they are displayed
exactly how they are in the file?

Personally I’d store everything in utf-8 and convert to/from that when
a file is uploaded or downloaded

Bonus Question:

In case anyone knows… The CSV file is being created with Microsoft
Excel. Is there a way to save the file as UTF-8 so I can just move on
with my life? :slight_smile:

Excel sucks at this. I’ve always ended up using utf-8 (and do check
that what you have is iso Latin 1 rather than something else - excel
can be very odd in this area)

Fred