Page 1 of 1

Encoding Problem

Posted: Sun Mar 15, 2009 10:23 pm
by amjadm
Hi All,

I have a database of html encoded strings which was originally windows-1256 (arabic) encoded i want to decoded it from html and unicode it and save it on a mysql database. The problem is the string is html decoded to Latin characters. If I echo the values and use <META http-equiv=Content-Type content="text/html;charset=windows-1256"> I can see the string properly (in arabic), but when inserting into database it is back to Latin

Example:

Code: Select all

 
<meta http-equiv="Content-Language" content="ar-sa">
<META http-equiv=Content-Type content="text/html;charset=windows-1256">
 
<?php
$s= html_entity_decode("&aring;&Ccedil;&auml;&iacute; &Ntilde;&Ocirc;&Ccedil;&Iuml; &Oacute;&atilde;&Uacute;&Ccedil;&auml; &Yacute;&Ntilde;&Iacute;");
echo $s;
?>
 
output on screen is readable. but the meta tags doesnt effect the internal php encoding, so it is inserted (i guess as utf-8) directly into the database before encoding conversion thats why its back in latin.

I tried mb_string functions like mb_convert_encoding but it doesnt take this "windows-1256" or "cp1256"
Warning: mb_convert_encoding() [function.mb-convert-encoding]: Unknown encoding "windows-1256" in ...
also tried some iconv stuff.

Any help is appreciated