Skip to content

BideoWego/html-entities-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

HTML Entities JS

A small class to encode and decode the most common HTML entities in a given string.

The class takes great care to ensure that the characters are encoded and decoded in the correct order to avoid character duplication.

See it in action on JsFiddle

Usage:

var text = '"&\'<> ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿŒœŠšŸƒˆ˜ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ–—‘’‚“”„†‡•…‰′″‹›‾⁄€ℑ℘ℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨⟩◊♠♣♥♦';

var encoded = HtmlEntities.encode(text);
var decoded = HtmlEntities.dencode(encoded);

// Get the character and entity map
var map = HtmlEntities.map;

REFERENCES

The current entity reference is here: elizabethcastro.com. Although I'm not sure when, it would be preferred to update to use W3C.

However, the most common entities are addressed.

About

A small class to encode and decode the most common HTML entities in a given string.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published