Hany
Hany

Reputation: 31

English/Arabic Encoding Problem

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

Upvotes: 1

Views: 6531

Answers (6)

hazem
hazem

Reputation: 1

you need to save php file with encoding (UTF-8).

Upvotes: 0

RDK
RDK

Reputation: 4560

Try add this AddDefaultCharset UTF-8 to your .htacess file

Upvotes: 0

brianreavis
brianreavis

Reputation: 11546

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" />

Upvotes: 1

Pekka
Pekka

Reputation: 449435

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

Upvotes: 1

Tatu Ulmanen
Tatu Ulmanen

Reputation: 124768

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

Upvotes: 0

Pascal MARTIN
Pascal MARTIN

Reputation: 401002

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 ^^ )

Upvotes: 2

Related Questions