Unicode string to show in javascript alert()

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
cohq82
Forum Commoner
Posts: 43
Joined: Mon Apr 21, 2008 8:38 pm

Unicode string to show in javascript alert()

Post by cohq82 »

I am writing a script to parse a unicode string to show on the screen in alert(). However, I don't know of a way to convert something like

$text = "T& #236;m ki& #7871;m n& #226;ng cao";

into a unicode string within HTML so alert() can show the right thing.

I use the function below but no luck.

Code: Select all

 
echo "<html><head>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body>";
echo mb_convert_encoding(html_entity_decode("T& #236;m ki& #7871;m n& #226;ng cao"), 'UTF-8');exit;
 
The mbstring extension is enabled by the way!

What can I do? Thanks
Post Reply