3

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?

dda
  • 6,030
  • 2
  • 25
  • 34
Moein Hosseini
  • 4,309
  • 15
  • 68
  • 106

1 Answers1

7

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

DaveRandom
  • 87,921
  • 11
  • 154
  • 174