Does anybody know how i can show a euro or other html entity in javascript alert windows?
-
Did you actually save your ASP page using UTF-8 encoding? – AnthonyWJones Mar 19 '09 at 09:41
-
I did not explicitly, no. Good idea! – Sander Versluys Mar 19 '09 at 09:48
-
&what provides easy lookup: http://ndpsoftware.com/&what/ – ndp Apr 05 '11 at 14:16
5 Answers
alert('\u20AC');

- 12,214
- 3
- 32
- 27
-
1I riffed on this and added a larger Unicode set and a responsive mobile version. I call it [&what;](http://ndpsoftware.com/&what/) – ndp Aug 06 '12 at 05:23
<script>alert("\u20ac");</script>
(20AC being the Unicode character for the euro sign.)

- 525
- 3
- 6
An alert box can show any characters that are in the codepage for the currently logged on session. So for example if the machine is using the 1252 codepage you can display the eurosign.
Its not clear what your trouble is, you javascript string should not have the characters encoded as entities anyway?
Edit:
If you specify UTF-8 in the HTML or as the Response.CharSet but you haven't actually saved the ASP file in UTF-8 format you will have problems with characters outside of ASCII.
ASP assumes static parts of an ASP file are in the required codepage already and sends it verbatim byte for byte, no encoding will happen.

- 187,081
- 35
- 232
- 306
-
that's true, it was my first thought, i'm using codepage 65001 in my asp classic page and utf-8 in my html, but still javascript would not show the euro sign correctly. – Sander Versluys Mar 19 '09 at 09:27
You can use the characters €, £, $ or ¥, which are standard ASCII, and can be produced directly on the keyboard.

- 50,140
- 28
- 121
- 140
for example, U+1234
is used like this: alert('\u1234')
.
For full list, you can see All Entity list:
1) http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
2) http://www.utf8-chartable.de/
3) http://rishida.net/tools/conversion/ (CONVERTER)

- 53,146
- 19
- 236
- 237