views:

36

answers:

1

I have two tables here - one is in UTF and holds Arabic text as it can be read. The other one has a different encoding however and the content is Arabic however in the database its displayed as

ÈöÓúãö Çááøåö ÇáÑøóÍúãóäö ÇáÑøóÍöíãö

I have to show data from both tables on the same page - the page is UTF encoded however I'm not sure if this can be done or if its possible. What do i do? My database is mysql and I'm using php.

Is it possible to convert the encoding of the contents of the other table into UTF8 btw?

+1  A: 

You have to use mb_convert_encoding() first, on everything, to make sure it's all in UTF-8 to begin with. http://us3.php.net/manual/en/function.mb-convert-encoding.php Then it should display, assuming your HTML's charset is UTF-8 and the users have the appropriate fonts installed.

Also, virtually all consoles and a great many free online SQL commanders (like PHPMyAdmin) are not UTF-8 aware and print out jibberish. I have not yet found a free SSH client that supports UTF-8; if it's a big deal, invest in SecureCRT.


EDIT: Excuse me. I don't read Arabic at all, but I did get Arabic back. please tell me if this is the correct text, and if so, accept this answer ;_)

ب?س?ك? افف?م? افر??ح?ك?ل? افر??ح?ٍك?

The code I used to get this was: header('Content-Type: text/html;charset=utf-8'); echo mb_convert_encoding('ÈöÓúãö Çááøåö ÇáÑøóÍúãóäö ÇáÑøóÍöíãö', 'utf-8', 'iso-8859-6');

I found the Arabic encoding via this page: http://a4esl.org/c/charset.html

Cheers!

hopeseekr
Its not working - mb_convert_encoding returns a false :( I'm not sure what the encoding of the data I have is to begin with..
Ali
Check my update, please.
hopeseekr
Sorry was stuck in work this whole month - I found the solution though on another site - running the text through: iconv("windows-1256","UTF-8", $data); worked just fine thanks for the help though
Ali