in reply to Re: Fine when written to text file, but unreadable when written to database table
in thread Fine when written to text file, but unreadable when written to database table

I use windows 2000 as my platform.

I use MSSQL.

THe collation used there is 'SQL_Latin1_General_CP850_CI_AI'

The downloaded file is an XML file. It uses 'encoding="UTF-8'
  • Comment on Re^2: Fine when written to text file, but unreadable when written to database table

Replies are listed 'Best First'.
Re^3: Fine when written to text file, but unreadable when written to database table
by graff (Chancellor) on Oct 16, 2006 at 08:18 UTC
    In that case, you should either convert the strings from utf8 to cp850 before you store them to the database, or else you should convert them after fetching them back from the database, before you print them to a file or display them. (See the "from_to" function in Encode.)

    Whatever you do, make sure the database content always has the same encoding for all text data. Mixing different encodings into a single database would be as bad as mixing them in a single paragraph -- it becomes impossible (or at least terribly difficult) to make the data coherent.

    (It is possible to have a table with different fields using different encodings; you could even have pairs of fields, like "name" and "name_encoding" so that the encoding of "name" is specified for each row, but that's more trouble than it's worth. Keep it simple.)