close

The Potato Chip Guitar, Fall 2014

Javascript and CSS Entity Conversion Calculator

Enter your HTML Entity Character number (such as &#2335 or just 2335 – ट) to get the CSS and JS values for that entity. Explanations on how to use the results are below.

Numeric Value (Decimal) CSS Value (Hex) JS Value (Hex) (). | |

If you can’t find the entity you want, try

Example of JavaScript Charater Entities and the DOM

    
  • In all but IE, this will be preceded by a heart

Notes:

  • Don’t know the numeric value of the entity you want to include? which may be a good place to start. Find the entity you are looking for there by appearance, then do a search for the numeric entity on the page. Or, you can simply search the . At some point I’ll add the rest of ‘em.
  • Remember that IE doesn’t understand the :before pseudoclass with content, and you would have to set the list-style-type as none, or you would get 2 bullets in CSS compliant browsers.
  • In javascript you can also use octal values instead of hexadecimal values for the first 255 or so characters. Yup, that’s trivia!

Including Entities without Encoding them

The reason I always use encoded entities is because I have no clue how to use my keyboard to get the right letters. It’s faster for me to look up the letter from then it is for me to look up the keyboard sequence to display the same character. For the following sample, I pulled up the "character map" that came with my OS. You can include odd characters if you correctly set your content-Type to UTF-8. That is the setting for this page, which allows for the following code without HTML or JS encoding.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

alert ( 'aº¾ aº¿ â' á »Ÿ áº" U¹ '); try it

The question is, short of , how do you tell your external scripts to be served up in UTF-8? This is external and doesn’t work. I tried <script type="text/javascript" src="/articles/entitycalculator.js" charset="utf-8"></script>, but it doesn’t work.


Previous     Next


TAGS


CATEGORIES

.