Alerting Special Characters using jQuery/JavaScript

Chamara Keragala picture Chamara Keragala · Jan 31, 2013 · Viewed 12.8k times · Source

How do i display a string with Special Characters like € in a Javascript/jQuery alert?

eg: I want to display a message box with "The Price is €10"

But when i use the below code:

alert("The Price is €10");

The Output shown in the message box is "The Price is €10", I want my output to be "The Price is €10".

Can some help me with this please? Thanks in advance.

Answer

Riju Mahna picture Riju Mahna · Jan 31, 2013

Use this as the alert. Works fine for me.

alert(' The Price is \u20AC 10');

The description is here : http://leftlogic.com/projects/entity-lookup/