Convert Windows-1256 to UTF-8

encode, php, utf-8, windows-1255

Solution

You need `iconv()`:

$utf8 = iconv('windows-1256', 'utf-8', $win1256);

...although `Supported character sets depend on the iconv implementation of your system.`, so YMMV.

If you want a 100% safe, works everywhere way to do this, the simplest thing to do would be to make a lookup table a use `str_replace()`.

Problem

I get the contents of a web page by curl, with charset set to Windows-1256. Now I want to insert this data into a MySQL database, with charset utf8_general_ci. Is there any way to do this?

Original source

Related problems