Skip to content Skip to sidebar Skip to footer

How I Can Solve My Php Web Page File Language Encoding?

I have a problem in Language Encoding in PHP as my php file should display both English and Arabic Characters. Some web page parts are static and others are dynamic (data comes fro

Solution 1:

Check your database connection, make sure the sybase_connect connects with UTF-8 as charset. See http://php.net/manual/en/function.sybase-connect.php

From the comment that you are using ODBC to connect: There seems to be an issue with PHP/ODBC and UTF8. Some suggestions are mentioned in this thread: Php/ODBC encoding problem

Solution 2:

Always use UTF-8.

Your first header is correct. Your first header is correct, except you should use single = instead of ==. Make sure you used header() function before sending any output to browser.

Open your files in a Unicode supporting editor like Editplus, notepad++ and while saving every source code or HTML file, use Save as and choose UTF-8 on the save as screen. If you use eclipse, import your project to eclipse, right click it and go to project settings, apply charset setting as utf-8 to all source code.

If there's something wrong with data coming from MySQL database, then use appropriate collation on any text storing column (varchar, blob etc). Those are the usual suggestions for it. If you use Sybase, then use Google for collation settings.

And don't change your font to Arabic; Arial already supports it.

Solution 3:

You seem to confuse something. Neither UTF-8 nor windows-1256 describe languages, they denote character sets/encodings. Although the character sets may contain characters that are typically used in certain languages, their use doesn’t say anything about the language.

Now as the characters of Windows-1256 are contained in Unicode’s character set and thus can be encoded with UTF-8, you should choose UTF-8 for both languages.

And if you want to declare the language for your contents, read the W3C’s tutorial on Declaring Language in XHTML and HTML.

In your case you could declare your primary document language as en (English) and parts of your document as ar (Arabic):

header('Content-Language: en');
header('Content-Type: text/html;charset=UTF-8');

echo '<p>The following is in Arabic: <spanlang="ar">العربية</span></p>';

Make sure to use UTF-8 for both.

Post a Comment for "How I Can Solve My Php Web Page File Language Encoding?"