html_entity_decode arabic chars to javacript var

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cyan
Forum Newbie
Posts: 3
Joined: Mon Jun 14, 2010 1:05 pm

html_entity_decode arabic chars to javacript var

Post 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
Attachments
javascript pop-up text
javascript pop-up text
bad-arabic.png (3.18 KiB) Viewed 328 times
Phoenixheart
Forum Contributor
Posts: 123
Joined: Tue Nov 16, 2004 7:46 am
Contact:

Re: html_entity_decode arabic chars to javacript var

Post by Phoenixheart »

Does the text appear correctly in the HTML source?
cyan
Forum Newbie
Posts: 3
Joined: Mon Jun 14, 2010 1:05 pm

Re: html_entity_decode arabic chars to javacript var

Post 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
cyan
Forum Newbie
Posts: 3
Joined: Mon Jun 14, 2010 1:05 pm

Re: html_entity_decode arabic chars to javacript var

Post by cyan »

i guess that means this is actually a javascript problem then,

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