Search code examples
htmlunicodeentityhtml-entitieshtml-encode

HTML Entity Vs. Unicode Code Point Which To Use


This might be a rookie question, but I've pondered it and can't find a definitive answer.

What should you use when coding out a special character in your website? HTML Entity Decimal, HTML Entity Hexadecimal, or Unicode Code Point. What are the differences and Best to use?

Example: ō

  • Unicode Code Point U+014D
  • HTML Entity (Decimal) ō
  • HTML Entity (Hexadecimal) ō
  • URL Escape Code %C5%8D

https://graphemica.com/%C5%8D


Solution

  • In general you should just write the literal character. If you write a web page in Japanese you don't convert every character to an HTML entity...

    If you have difficulty typing the character, it may make sense to use a named entity, like Ψ. As long as you aren't making a whole document into entities it doesn't matter if you have a few characters as entities rather than literal characters.

    Also two of your four options are not applicable:

    • Unicode Code Point U+014D: You can't write "unicode code points" to anything, they're not a data format, it's a lookup number for the Unicode spec.
    • URL Escape Code %C5%8D: This doesn't work in HTML, it's only used in query strings.