Problem with different encodings between databases

2

I'm creating an application that needs to grab some data that is in a SQL Server database with iso-8859-1 encoding, and insert into a MySQL database with utf-8 encoding.

Some words with accents are giving error when inserting into MySQL database.

Incorrect string value: '\xC7AFR\xC3O' for column 'produto' at row 1

The word that appears with error is Saffron. How can I work around this error and insert the record into the bank?

obs: I'm using PHP

    
asked by anonymous 04.08.2015 / 14:29

1 answer

1

Try using this function to convert the string to UTF-8:

mb_convert_encoding($string, "UTF-8", mb_detect_encoding($string, "UTF-8, ISO-8859-1, ISO-8859-15", true));

    
04.08.2015 / 17:29