Page 1 of 1

html_entity_decode arabic chars to javacript var

Posted: Mon Jun 14, 2010 1:22 pm
by cyan
Hi everyone,

I hope someone here will be able to help me out with this.

I have some Arabic text stored in PHP as follows:

$JScriptMotVide = '«من فضلك اكتب كلمة رئيسية»';

If I output this variable in html it displays perfectly in Arabic: «من فضلك اكتب كلمة رئيسية»

The problem is when this string is used in a javascript pop-up. It is passed to the javascript variable using html_entity_decode:

<script type="text/javascript">
var emptyStr = "<?php echo html_entity_decode($JScriptMotVide, ENT_QUOTES, 'UTF-8' ) ?>";
</script>

When the text is displayed in the pop-up, it shows as seen in the attached image - sort of Arabic, with some other weird characters in there...

If anyone has experienced similar problems and has any suggestions please let me know.

cyan

Re: html_entity_decode arabic chars to javacript var

Posted: Mon Jun 14, 2010 9:30 pm
by Phoenixheart
Does the text appear correctly in the HTML source?

Re: html_entity_decode arabic chars to javacript var

Posted: Tue Jun 15, 2010 11:39 am
by cyan
Hi,

What I see in the HTML source is this, which is the correct arabic characters:

var emptyStr = "«من فضلك اكتب كلمة رئيسية»";

Thanks for any suggestions,

cyan

Re: html_entity_decode arabic chars to javacript var

Posted: Thu Jun 17, 2010 12:47 pm
by cyan
i guess that means this is actually a javascript problem then,

i'll try looking for some help on their forums.