Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Windows-1256 to UTF-8

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?

like image 963
Moein Hosseini Avatar asked Sep 18 '25 04:09

Moein Hosseini


1 Answers

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().

like image 140
DaveRandom Avatar answered Sep 20 '25 20:09

DaveRandom