Javascripts: Issue with accented and special characters

This article explains how to resolve issues with accented characters in JavaScript when they do not display correctly in functions like alert().

Important: This solution is aimed at advanced users or those with programming knowledge. Before using Unicode escapes, verify that your page declares UTF-8 (<meta charset="UTF-8">) and that the .js file is saved in UTF-8.

Problem

When inserting strings with JavaScript (for example in alert()), accents may look incorrect. HTML entities like &aacute; do not work inside JavaScript strings: you must use the direct character in UTF-8 or its Unicode escape.

Solution — Unicode Escapes

Use the format \uXXXX, where each X is a hexadecimal digit.

Example:

// Instead of:
alert("cartograf\u00EDa");  // cartografía

// Or with the direct UTF-8 character (if the file is UTF-8):
alert("cartografía");

For lowercase í: \u00ED

Spanish characters

Character HTML Unicode (JS)
Á &Aacute; \u00C1
á &aacute; \u00E1
É &Eacute; \u00C9
é &eacute; \u00E9
Í &Iacute; \u00CD
í &iacute; \u00ED
Ó &Oacute; \u00D3
ó &oacute; \u00F3
Ú &Uacute; \u00DA
ú &uacute; \u00FA
Ü &Uuml; \u00DC
ü &uuml; \u00FC
Ñ &Ntilde; \u00D1
ñ &ntilde; \u00F1

Other special characters

Character HTML Unicode (JS)
& &amp; \u0026
< &lt; \u003C
> &gt; \u003E
" &quot; \u0022
' &apos; \u0027
NBSP space &nbsp; \u00A0
© &copy; \u00A9
® &reg; \u00AE
€ &euro; \u20AC
¼ &frac14; \u00BC
½ &frac12; \u00BD
¾ &frac34; \u00BE

Need help?

If the issue persists on your hosted site, contact technical support from the client portal or the site's online chat.

  • Javascripts problema con carácteres, javascripts errores, caracteres acentuados errores, caracteres especiales, no imprime caracter con acento, cambiar configuracion email plesk
  • 21 Users Found This Useful
Was this answer helpful?

Related Articles

I purchased the service but my domain does not work

This article explains the most frequent causes why a domain does not work and how to check them....

Out of space, how to fix it

This article explains what to do if you run out of space on your contracted Web Hosting service....

Bandwidth limit exceeded, my website is not working

This article explains what the Bandwidth limit exceeded message means and what options you have...

Traceroute and obtaining IP address

This article explains how to perform a traceroute (tracert) and how to obtain the public IP of...

Common issues related to FTP connections

This article describes solutions to frequent problems in FTP connections. The examples use the...