xslt, javascript and unescaped html entities

ok. long story, short answer: it seems that with some libxslt versions the xslt processor leaves the content of a <script/> element unescaped when using the html output method, with others not … therefore the following is recommended: <script type=”text/javascript”> <xsl:value-of select=”/some/node”/> <xsl:text disable-output-escaping=”yes”> // ^ does the trick … for (var i = 0; … Read more

Decoding all HTML Entities

Then maybe you will need the HttpUtility.HtmlDecode?. It should work, you just need to add a reference to System.Web. At least this was the way in .Net Framework < 4. For example the following code: MessageBox.Show(HttpUtility.HtmlDecode(“&amp;&copy;”)); Worked and the output was as expected (ampersand and copyright symbol). Are you sure the problem is within HtmlDecode … Read more

is there a mysql function to decode html entities?

You can create function like below DELIMITER $$ DROP FUNCTION IF EXISTS `HTML_UnEncode`$$ CREATE FUNCTION `HTML_UnEncode`(X VARCHAR(255)) RETURNS VARCHAR(255) CHARSET latin1 DETERMINISTIC BEGIN DECLARE TextString VARCHAR(255) ; SET TextString = X ; #quotation mark IF INSTR( X , ‘&quot;’ ) THEN SET TextString = REPLACE(TextString, ‘&quot;’,'”‘) ; END IF ; #apostrophe IF INSTR( X , … Read more

Decode HTML entities in JavaScript? [duplicate]

I have on my utility belt this tiny function always: function htmlDecode(input){ var e = document.createElement(‘div’); e.innerHTML = input; return e.childNodes[0].nodeValue; } htmlDecode(“&amp;”); // “&” htmlDecode(“&gt;”); // “>” It will work for all HTML Entities. Edit: Since you aren’t in a DOM environment, I think you will have to do it by the “hard” way: … Read more

Converting & to & in Objective-C [duplicate]

Check out my NSString category for HTML. Here are the methods available: // Strips HTML tags & comments, removes extra whitespace and decodes HTML character entities. – (NSString *)stringByConvertingHTMLToPlainText; // Decode all HTML entities using GTM. – (NSString *)stringByDecodingHTMLEntities; // Encode all HTML entities using GTM. – (NSString *)stringByEncodingHTMLEntities; // Minimal unicode encoding will only … Read more

Replacing   from javascript dom text node

This is much easier than you’re making it. The text node will not have the literal string “&nbsp;” in it, it’ll have have the corresponding character with code 160. function replaceNbsps(str) { var re = new RegExp(String.fromCharCode(160), “g”); return str.replace(re, ” “); } textNode.nodeValue = replaceNbsps(textNode.nodeValue); UPDATE Even easier: textNode.nodeValue = textNode.nodeValue.replace(/\u00a0/g, ” “);

When should one use HTML entities?

Based on the comments I have received, I looked into this a little further. It seems that currently the best practice is to forgo using HTML entities and use the actual UTF-8 character instead. The reasons listed are as follows: UTF-8 encodings are easier to read and edit for those who understand what the character … Read more