5

I need convert arabic letters in htmlentities symbols. Codepage: ISO-8859-1.

سك - this is arabic symbol for example.

htmlentities("سك")

returns:

س� 

How can I get from this symbol the html-entities سك?

Anatoly
  • 141
  • 1
  • 2
  • 8
  • possible duplicate of [How to convert some multibyte characters into its numeric html entity using PHP?](http://stackoverflow.com/questions/5123638/how-to-convert-some-multibyte-characters-into-its-numeric-html-entity-using-php) – Pekka Sep 14 '11 at 12:03

3 Answers3

6

htmlentities() can do only characters that have named entities. See this question on how to convert arbitrary characters into numeric entities.

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • @Anatoly ah, you want numeric entities, in that case, htmlentities() indeed won't work. I'll delete this answer soon. May I ask what you need entities for in the first place? – Pekka Sep 14 '11 at 11:42
  • You did't know how i can get the numeric entities? I have multilanguage site in widows-1251, and only numeric entities appear normal – Anatoly Sep 14 '11 at 11:58
  • @Anatoly Hmm, I see. The much better approach would be using UTF-8 as the output encoding - it can display all alphabets properly. If that's not an option, see http://stackoverflow.com/questions/5123638/how-to-convert-some-multibyte-characters-into-its-numeric-html-entity-using-php – Pekka Sep 14 '11 at 12:03
3

You're probably not targeting the correct charset. Try: htmlentities('سك', ENT_QUOTES, 'UTF-8');

Cyclone
  • 17,939
  • 45
  • 124
  • 193
0

i'm using a function to make sure there are no html code or cotation posted by user

function cleartext($x1){

    $x1 = str_replace('"','',$x1);
    $x1 = str_replace("'",'',$x1);
    $x1 = htmlentities($x1, ENT_QUOTES, 'UTF-8');
    return $x1;
}

so thank for ( ENT_QUOTES, 'UTF-8' ) it helped me to find what am looking for