tags:

views:

430

answers:

4

Hi

I am designing a web page this web page should support

English and Arabic languages

my problem is : Arabic characters doesn't appear in its way

it appears some thing like that "أهلاً يا معلم "

I have tried to change the encoding of this page with the following tag

<META CONTENT="text/html; charset=windows-1256" HTTP-EQUIV="Content-Type">

but it didn't work and I tried the "utf-8" but it doesn't work either?

thanks for reading my question

+2  A: 

You need to change more than that : ideally, everything should be set to, or encoded in, UTF-8 :

  • the source code of your scripts / pages
    • configuring your IDE / editor to encode in UTF-8 by default might be a good idea, here
  • the data in your database -- if you are using one
    • the connection between PHP and your DB
  • the meta tag, like you did -- eventually ; not sure it's that usefull, actually
  • the HTTP Content-type header (see point 14.17 or the RFC, for instance)
  • well, everything.

For the last part, this should do the trick, in PHP :

header('Content-type: text/html; charset=UTF-8');

(You might need to adjust it, depending on your... content-type ^^ )

Pascal MARTIN
A: 

Set your page's encoding to UTF-8 using the meta method and make sure your files are saved in UTF-8 (in your editor, check that the encoding used is UTF-8).

Tatu Ulmanen
I checked it for more than one timesThe source code is utf-8the page encoding is utf-8 also but no result !!!
Hany
+1  A: 

The answer to your question is most certainly UTF-8.

As good basic reading, I recommend The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

If you want more detailed help here, you will have to describe what exactly you do: Where your data comes from, whether you use a CMS and so on. (Update: @Pascal Martin already mentioned all the important points).

Pekka
A: 

Here's the bulletproof way I use. First instruct PHP to deal with UTF8 all the way:

mb_internal_encoding('UTF-8');
iconv_set_encoding('internal_encoding', 'UTF-8');
iconv_set_encoding('output_encoding',   'UTF-8');
header('Content-type: text/html; charset=UTF-8');

Then double-check that the browser knows that we're using the UTF scheme:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
brianreavis