How to get numeric, hexadecimal and ISO of html-entities in JavaScript -


is there function in javascript can give me conversion html entity (name) either numeric, or hexadecimal, or iso slash character (to used in css)?

e.g.,

  • the cent symbol's ( ¢ ) html : ¢.
  • its numeric value ¢ can used in html mark-up well
  • hexadecimal value %a2
  • iso \00a2 - can use directly in css content property.

like follows:

.cents:after {     font-style: italic;     content: "\00a2"; } 

i more interested in iso value therefore.

the cent symbol's ( ¢ ) html : ¢.

//will need work against list of items or char code set need 

its numeric value ¢ can used in html mark-up well

'&#' + '¢'.charcodeat(0); 

hexadecimal value %a2

escape('¢'); 

iso \00a2 - can use directly in css content property.

var iso = ['\\', '0', '0', '0', '0']; var hex = '¢'.charcodeat(0).tostring(16).split('');  for(var i=4; >= 0 && hex.length > 0 ; i--){     iso[i] = hex.pop(); }  iso.join('') 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -