I am aware that special html-entities like
or ö
or ð
cannot be incorporated within a css block like the following:
div.test:before {
content:"text with html-entities like ` ` or `ö` or `ð`";
}
There is a valuable discussion with insightful responses addressing this issue at: Adding HTML entities using CSS content
However, I am currently fetching strings containing html-entities from a server via AJAX. The JavaScript executing on the user's browser processes the text with html-entities and converts it into style-content instead of directly placing it as a text within an html element's content. This technique prevents content theft through copy & paste. Content residing within the css-content is particularly challenging to copy. Despite this approach being effective, the persisting issue remains with html-entities.
Therefore, I am looking for a method to dynamically convert html-entities into unicode escape-sequences. This conversion can be done either on the server using a perl script or on the client side with JavaScript. However, I am hesitant to manually create a function that contains a comprehensive list of all existing named entities. The html5 specification includes over 2200 named entities, as documented here: http://www.w3.org/TR/2011/WD-html5-20110113/named-character-references.html I want to avoid updating this function each time the list of entities is modified. (Numeric entities pose no challenge.)
Is there a clever workaround to achieve this conversion using JavaScript? Perhaps by manipulating the DOM through adding, reading, and removing content? (I am utilizing jQuery)