user813720
user813720

Reputation: 451

How can I convert latin1 data to UTF8 on mysql insert or update?

I am getting data nightly from a web service that stores their fields in latin, but my database is in utf8. Is it possible to convert the data string to utf8 when I update or insert the record?

Upvotes: 1

Views: 6413

Answers (2)

Philip
Philip

Reputation: 3799

Have a look at the features provided by the Multibyte String Functions in PHP. Specifically, I think that the mb_convert_encoding is the function you are looking for.

$output = mb_convert_encoding ($input, 'UTF-8', 'ISO-8859-1');

ISO-8859-1 is the official encoding standard for "Latin-1", as per Wikipedia.

Upvotes: 0

hjpotter92
hjpotter92

Reputation: 80629

$output = utf8_encode ( $inputstring );

Read more about utf8_encode

Upvotes: 2

Related Questions