Accented Characters and Ligatures
in HTML and JavaScript

JavaScript FAQ | JavaScript Strings and RegExp FAQ  

Question: Can I display accented characters or ligatures as part of JavaScript output?

Answer: You can include accented characters and ligatures in JavaScript strings and/or display them on your HTML pages using the following encodings for the letters:

  • hexadecimal codes \xXX in JavaScript strings; e.g. ñ is \xF1
  • Unicode hex codes \uXXXX in JavaScript strings; e.g. š is \u0161
  • HTML entities; for example, ñ is ñ and š is š
  • numeric HTML entities; e.g. ñ is ñ and š is š
  • unescape with a suitable argument; e.g. ñ is unescape('%F1')
  • decodeURI with a suitable argument; e.g. ñ is decodeURI('%C3%B1')
    Example 1:  Here is a test for the capital letter U-umlaut (Ü):
    document.write('\xDC')              // 
    document.write('Ü')            // 
    document.write('Ü')            // 
    document.write(unescape('%DC'))     // 
    document.write(decodeURI('%C3%9C')) // 
    
    Example 2:  Here is a test for the Latin OE ligature (Œ):
    document.write('\u0152')            // 
    document.write('Œ')            // 
    document.write('Œ')           // 
    document.write(unescape('%u0152'))  // 
    document.write(decodeURI('%C5%92')) // 
    

    To display an accented character in a JavaScript alert message or a confirm dialog box, use the hexadecimal code of the character, for example:

    alert('\xC5ngstr\xF6m is a unit of length.') //Try it!
    

    The following table lists the HTML entities, character codes, and URL-encodings for accented Latin letters and ligatures. (Letters that do not have standard HTML entities are not included. Still, those letters can be rendered, similar to the above examples, as long as you know the character codes \xXX or \uXXXX or &#XXX; e.g. the letters č and can be rendered using č and ℓ respectively.) See also Greek letters, Mathematical symbols and URL-encoding.

  • chr  HexCode   Numeric   HTML entity  escape(chr)  encodeURI(chr)   Description
    À\xC0ÀÀ%C0%C3%80latin capital letter A with grave
    Á\xC1ÁÁ%C1%C3%81latin capital letter A with acute
    Â\xC2ÂÂ%C2%C3%82latin capital letter A with circumflex
    Ã\xC3ÃÃ%C3%C3%83latin capital letter A with tilde
    Ä\xC4ÄÄ%C4%C3%84latin capital letter A with diaeresis
    Å\xC5ÅÅ%C5%C3%85latin capital letter A with ring above
    Æ\xC6ÆÆ%C6%C3%86latin capital ligature AE
    Ç\xC7ÇÇ%C7%C3%87latin capital letter C with cedilla
    È\xC8ÈÈ%C8%C3%88latin capital letter E with grave
    É\xC9ÉÉ%C9%C3%89latin capital letter E with acute
    Ê\xCAÊÊ%CA%C3%8Alatin capital letter E with circumflex
    Ë\xCBËË%CB%C3%8Blatin capital letter E with diaeresis
    Ì\xCCÌÌ%CC%C3%8Clatin capital letter I with grave
    Í\xCDÍÍ%CD%C3%8Dlatin capital letter I with acute
    Î\xCEÎÎ%CE%C3%8Elatin capital letter I with circumflex
    Ï\xCFÏÏ%CF%C3%8Flatin capital letter I with diaeresis
    Ð\xD0ÐÐ%D0%C3%90latin capital letter ETH
    Ñ\xD1ÑÑ%D1%C3%91latin capital letter N with tilde
    Ò\xD2ÒÒ%D2%C3%92latin capital letter O with grave
    Ó\xD3ÓÓ%D3%C3%93latin capital letter O with acute
    Ô\xD4ÔÔ%D4%C3%94latin capital letter O with circumflex
    Õ\xD5ÕÕ%D5%C3%95latin capital letter O with tilde
    Ö\xD6ÖÖ%D6%C3%96latin capital letter O with diaeresis
    Ø\xD8ØØ%D8%C3%98latin capital letter O with stroke
    Ù\xD9ÙÙ%D9%C3%99latin capital letter U with grave
    Ú\xDAÚÚ%DA%C3%9Alatin capital letter U with acute
    Û\xDBÛÛ%DB%C3%9Blatin capital letter U with circumflex
    Ü\xDCÜÜ%DC%C3%9Clatin capital letter U with diaeresis
    Ý\xDDÝÝ%DD%C3%9Dlatin capital letter Y with acute
    Þ\xDEÞÞ%DE%C3%9Elatin capital letter THORN
    ß\xDFßß%DF%C3%9Flatin small letter sharp s = ess-zed
    à\xE0àà%E0%C3%A0latin small letter a with grave
    á\xE1áá%E1%C3%A1latin small letter a with acute
    â\xE2ââ%E2%C3%A2latin small letter a with circumflex
    ã\xE3ãã%E3%C3%A3latin small letter a with tilde
    ä\xE4ää%E4%C3%A4latin small letter a with diaeresis
    å\xE5åå%E5%C3%A5latin small letter a with ring above
    æ\xE6ææ%E6%C3%A6latin small ligature ae
    ç\xE7çç%E7%C3%A7latin small letter c with cedilla
    è\xE8èè%E8%C3%A8latin small letter e with grave
    é\xE9éé%E9%C3%A9latin small letter e with acute
    ê\xEAêê%EA%C3%AAlatin small letter e with circumflex
    ë\xEBëë%EB%C3%ABlatin small letter e with diaeresis
    ì\xECìì%EC%C3%AClatin small letter i with grave
    í\xEDíí%ED%C3%ADlatin small letter i with acute
    î\xEEîî%EE%C3%AElatin small letter i with circumflex
    ï\xEFïï%EF%C3%AFlatin small letter i with diaeresis
    ð\xF0ðð%F0%C3%B0latin small letter eth
    ñ\xF1ññ%F1%C3%B1latin small letter n with tilde
    ò\xF2òò%F2%C3%B2latin small letter o with grave
    ó\xF3óó%F3%C3%B3latin small letter o with acute
    ô\xF4ôô%F4%C3%B4latin small letter o with circumflex
    õ\xF5õõ%F5%C3%B5latin small letter o with tilde
    ö\xF6öö%F6%C3%B6latin small letter o with diaeresis
    ø\xF8øø%F8%C3%B8latin small letter o with stroke
    ù\xF9ùù%F9%C3%B9latin small letter u with grave
    ú\xFAúú%FA%C3%BAlatin small letter u with acute
    û\xFBûû%FB%C3%BBlatin small letter u with circumflex
    ü\xFCüü%FC%C3%BClatin small letter u with diaeresis
    ý\xFDýý%FD%C3%BDlatin small letter y with acute
    þ\xFEþþ%FE%C3%BElatin small letter thorn
    ÿ\xFFÿÿ%FF%C3%BFlatin small letter y with diaeresis
    Œ\u0152ŒŒ%u0152%C5%92latin capital ligature OE
    œ\u0153œœ%u0153%C5%93latin small ligature oe
    Š\u0160ŠŠ%u0160%C5%A0latin capital letter S with caron
    š\u0161šš%u0161%C5%A1latin small letter s with caron
    Ÿ\u0178ŸŸ%u0178%C5%B8latin capital letter Y with diaeresis
    ƒ\u0192ƒƒ%u0192%C6%92latin small f with hook

    Finally, if you cannot find the desired character, you can create one using the following combining accents:

    Combining accent   HexCode  Numeric entity  Example
    Grave accent        \u0300     ̀       document.write('à') // 
    Acute accent        \u0301     ́       document.write('á') // 
    Circumflex accent   \u0302     ̂       document.write('ê') // 
    Tilde               \u0303     ̃       document.write('ã') // 
    Macron              \u0304     ̄       document.write('ā') //  
    Breve               \u0306     ̆       document.write('ă') //  
    Dot                 \u0307     ̇       document.write('ż') // 
    Diaeresis (umlaut)  \u0308     ̈       document.write('ä') // 
    Hook                \u0309     ̉       document.write('ả') // 
    Ring                \u030A     ̊       document.write('å') // 
    Double acute        \u030B     ̋       document.write('ő') // 
    Caron (haček)       \u030C     ̌       document.write('ž') // 
    
    There are over a hundred combining accents spanning the Unicode range from \u0300 to \u036F.
    Not all letter/accent combinations are supported; the results will vary from browser to browser.

    See also:

  • How do I convert a string to URL encoding?
  • Greek Letters in HTML and JavaScript
  • Special Symbols and Mathematical Symbols
  • W3C Character Entity References in HTML 4 (www.w3.org)

    Copyright © 1999-2011, JavaScripter.net.