Skip to content

Categories:

vbscript to convert html into numeric entities for xml file (rss feed)

After numerous failures getting through the http://feedvalidator.org because of some remnants left by word or other text editors, I implented the replacement function found at http://www.texaswebdevelopers.com/examples/sql-injection-protection.asp.

For the german text we work on it was changed slightly to include german umlaute.
Here’s the function:

FUNCTION htmlEntities(strString)
Dim strOutput
strOutput = strString

strOutput = replace(strOutput,Chr(10),”")
strOutput = replace(strOutput,Chr(13),”")
strOutput = replace(strOutput,”&”,”&”)
strOutput = replace(strOutput,”‘”,”'”)
strOutput = replace(strOutput,”§”,”§”)
strOutput = replace(strOutput,”©”,”©”)
strOutput = replace(strOutput,”®”,”®”)
strOutput = replace(strOutput,”¦”,”¦”)
strOutput = replace(strOutput,”‘”,”"”)
strOutput = replace(strOutput,”<”,”&#60;”)
strOutput = replace(strOutput,”>”,”&#62;”)
strOutput = replace(strOutput,”–”,”&#8211;”)
strOutput = replace(strOutput,”—”,”&#62;”)
strOutput = replace(strOutput,”‘”,”&#8216;”)
strOutput = replace(strOutput,”’”,”&#8217;”)
strOutput = replace(strOutput,”“”,”&#8220;”)
strOutput = replace(strOutput,”””,”&#8221;”)
strOutput = replace(strOutput,”„”,”&#8222;”)
strOutput = replace(strOutput,”†”,”&#8224;”)
strOutput = replace(strOutput,”‡”,”&#8216;”)
strOutput = replace(strOutput,”…”,”&#8230;”)
strOutput = replace(strOutput,”¡”,”&#161;”)
strOutput = replace(strOutput,”¤”,”&#164;”)
strOutput = replace(strOutput,”¢”,”&#162;”)
strOutput = replace(strOutput,”£”,”&#163;”)
strOutput = replace(strOutput,”¥”,”&#165;”)
strOutput = replace(strOutput,”¦”,”&#166;”)
strOutput = replace(strOutput,”§”,”&#167;”)
strOutput = replace(strOutput,”¨”,”&#168;”)
strOutput = replace(strOutput,”©”,”&#169;”)
strOutput = replace(strOutput,”ª”,”&#170;”)
strOutput = replace(strOutput,”«”,”&#171;”)
strOutput = replace(strOutput,”¬”,”&#172;”)
strOutput = replace(strOutput,”®”,”&#174;”)
strOutput = replace(strOutput,”™”,”&#8482;”)
strOutput = replace(strOutput,”¯”,”&#175;”)
strOutput = replace(strOutput,”°”,”&#176;”)
strOutput = replace(strOutput,”±”,”&#177;”)
strOutput = replace(strOutput,”²”,”&#178;”)
strOutput = replace(strOutput,”³”,”&#179;”)
strOutput = replace(strOutput,”´”,”&#180;”)
strOutput = replace(strOutput,”µ”,”&#181;”)
strOutput = replace(strOutput,”¶”,”&#182;”)
strOutput = replace(strOutput,”·”,”&#183;”)
strOutput = replace(strOutput,”¸”,”&#184;”)
strOutput = replace(strOutput,”¹”,”&#185;”)
strOutput = replace(strOutput,”º”,”&#186;”)
strOutput = replace(strOutput,”»”,”&#187;”)
strOutput = replace(strOutput,”¼”,”&#188;”)
strOutput = replace(strOutput,”½”,”&#189;”)
strOutput = replace(strOutput,”¾”,”&#190;”)
strOutput = replace(strOutput,”¿”,”&#191;”)
strOutput = replace(strOutput,”×”,”&#215;”)
strOutput = replace(strOutput,”÷”,”&#247;”)
strOutput = replace(strOutput,”‰”,”&#8240;”)
strOutput = replace(strOutput,”‹”,”&#8249;”)
strOutput = replace(strOutput,”›”,”&#8250;”)
strOutput = replace(strOutput,”€”,”&#8364;”)
strOutput = replace(strOutput,”&quot;”,”&#34;”) 
strOutput = replace(strOutput,”&apos;”,”&#39;”)
strOutput = replace(strOutput,”&amp;”,”&#38;”)
strOutput = replace(strOutput,”&lt;”,”&#60;”)
strOutput = replace(strOutput,”&gt;”,”&#62;”)
strOutput = replace(strOutput,”&nbsp;”,” &#160;”)               
strOutput = replace(strOutput,”&ndash;”,”&#8211;”)
strOutput = replace(strOutput,”&mdash;”,”&#8212;”)
strOutput = replace(strOutput,”&lsquo;”,”&#8216;”)
strOutput = replace(strOutput,”&rsquo;”,”&#8217;”)
strOutput = replace(strOutput,”&sbquo;”,”&#8218;”)
strOutput = replace(strOutput,”&ldquo;”,”&#8220;”)
strOutput = replace(strOutput,”&rdquo;”,”&#8221;”)
strOutput = replace(strOutput,”&bdquo;”,”&#8222;”)
strOutput = replace(strOutput,”&dagger;”,”&#8224;”)
strOutput = replace(strOutput,”&Dagger;”,”&#8225;”)
strOutput = replace(strOutput,”&hellip;”,”&#8230;”)
strOutput = replace(strOutput,”&iexcl;”,”&#161;”)
strOutput = replace(strOutput,”&curren;”,”&#164;”)
strOutput = replace(strOutput,”&cent;”,”&#162;”)
strOutput = replace(strOutput,”&pound;”,”&#163;”)
strOutput = replace(strOutput,”&yen;”,”&#165;”)
strOutput = replace(strOutput,”&brvbar;”,”&#166;”)
strOutput = replace(strOutput,”&sect;”,”&#167;”)
strOutput = replace(strOutput,”&uml;”,”&#168;”)
strOutput = replace(strOutput,”&copy;”,”&#169;”)
strOutput = replace(strOutput,”&ordf;”,”&#170;”)
strOutput = replace(strOutput,”&laquo;”,”&#171;”)
strOutput = replace(strOutput,”&not;”,”&#172;”)
strOutput = replace(strOutput,”&shy;”,”&#173;”)
strOutput = replace(strOutput,”&reg;”,”&#174;”)
strOutput = replace(strOutput,”&trade;”,”&#8482;”)
strOutput = replace(strOutput,”&macr;”,”&#175;”)
strOutput = replace(strOutput,”&deg;”,”&#176;”)
strOutput = replace(strOutput,”&plusmn;”,”&#177;”)
strOutput = replace(strOutput,”&sup2;”,”&#178;”)
strOutput = replace(strOutput,”&sup3;”,”&#179;”)
strOutput = replace(strOutput,”&acute;”,”&#180;”)
strOutput = replace(strOutput,”&micro;”,”&#181;”)
strOutput = replace(strOutput,”&para;”,”&#182;”)
strOutput = replace(strOutput,”&middot;”,”&#183;”)
strOutput = replace(strOutput,”&cedil;”,”&#184;”)
strOutput = replace(strOutput,”&sup1;”,”&#185;”)
strOutput = replace(strOutput,”&ordm;”,”&#186;”)
strOutput = replace(strOutput,”&raquo;”,”&#187;”)
strOutput = replace(strOutput,”&frac14;”,”&#188;”)
strOutput = replace(strOutput,”&frac12;”,”&#189;”)
strOutput = replace(strOutput,”&frac34;”,”&#190;”)
strOutput = replace(strOutput,”&iquest;”,”&#191;”)
strOutput = replace(strOutput,”&times;”,”&#215;”)
strOutput = replace(strOutput,”&divide;”,”&#247;”)
strOutput = replace(strOutput,”&Agrave;”,”&#192;”)
strOutput = replace(strOutput,”&Aacute;”,”&#193;”)
strOutput = replace(strOutput,”&Acirc;”,”&#194;”)
strOutput = replace(strOutput,”&Atilde;”,”&#195;”)
strOutput = replace(strOutput,”&Auml;”,”&#196;”)
strOutput = replace(strOutput,”&Aring;”,”&#197;”)
strOutput = replace(strOutput,”&AElig;”,”&#198;”)
strOutput = replace(strOutput,”&Ccedil;”,”&#199;”)
strOutput = replace(strOutput,”&Egrave;”,”&#200;”)
strOutput = replace(strOutput,”&Eacute;”,”&#201;”)
strOutput = replace(strOutput,”&Ecirc;”,”&#202;”)
strOutput = replace(strOutput,”&Euml;”,”&#203;”)
strOutput = replace(strOutput,”&Igrave;”,”&#204;”)
strOutput = replace(strOutput,”&Iacute;”,”&#205;”)
strOutput = replace(strOutput,”&Icirc;”,”&#206;”)
strOutput = replace(strOutput,”&Iuml;”,”&#207;”)
strOutput = replace(strOutput,”&ETH;”,”&#208;”)
strOutput = replace(strOutput,”&Ntilde;”,”&#209;”)
strOutput = replace(strOutput,”&Ograve;”,”&#210;”)
strOutput = replace(strOutput,”&Oacute;”,”&#211;”)
strOutput = replace(strOutput,”&Ocirc;”,”&#212;”)
strOutput = replace(strOutput,”&Otilde;”,”&#213;”)
strOutput = replace(strOutput,”&Ouml;”,”&#214;”)
strOutput = replace(strOutput,”&Oslash;”,”&#216;”)
strOutput = replace(strOutput,”&Ugrave;”,”&#217;”)
strOutput = replace(strOutput,”&Uacute;”,”&#218;”)
strOutput = replace(strOutput,”&Ucirc;”,”&#219;”)
strOutput = replace(strOutput,”&Uuml;”,”&#220;”)
strOutput = replace(strOutput,”&Yacute;”,”&#221;”)
strOutput = replace(strOutput,”&THORN;”,”&#222;”)
strOutput = replace(strOutput,”&szlig;”,”&#223;”)
strOutput = replace(strOutput,”&agrave;”,”&#224;”)
strOutput = replace(strOutput,”&aacute;”,”&#225;”)
strOutput = replace(strOutput,”&acirc;”,”&#226;”)
strOutput = replace(strOutput,”&atilde;”,”&#227;”)
strOutput = replace(strOutput,”&auml;”,”&#228;”)
strOutput = replace(strOutput,”&aring;”,”&#229;”)
strOutput = replace(strOutput,”&aelig;”,”&#230;”)
strOutput = replace(strOutput,”&ccedil;”,”&#231;”)
strOutput = replace(strOutput,”&egrave;”,”&#232;”)
strOutput = replace(strOutput,”&eacute;”,”&#233;”)
strOutput = replace(strOutput,”&ecirc;”,”&#234;”)
strOutput = replace(strOutput,”&euml;”,”&#235;”)
strOutput = replace(strOutput,”&igrave;”,”&#236;”)
strOutput = replace(strOutput,”&iacute;”,”&#237;”)
strOutput = replace(strOutput,”&icirc;”,”&#238;”)
strOutput = replace(strOutput,”&iuml;”,”&#239;”)
strOutput = replace(strOutput,”&eth;”,”&#240;”)
strOutput = replace(strOutput,”&ntilde;”,”&#241;”)
strOutput = replace(strOutput,”&ograve;”,”&#242;”)
strOutput = replace(strOutput,”&oacute;”,”&#243;”)
strOutput = replace(strOutput,”&ocirc;”,”&#244;”)
strOutput = replace(strOutput,”&otilde;”,”&#245;”)
strOutput = replace(strOutput,”&ouml;”,”&#246;”)
strOutput = replace(strOutput,”&oslash;”,”&#248;”)
strOutput = replace(strOutput,”&ugrave;”,”&#249;”)
strOutput = replace(strOutput,”&uacute;”,”&#250;”)
strOutput = replace(strOutput,”&ucirc;”,”&#251;”)
strOutput = replace(strOutput,”&uuml;”,”&#252;”)
strOutput = replace(strOutput,”&yacute;”,”&#253;”)
strOutput = replace(strOutput,”&thorn;”,”&#254;”)
strOutput = replace(strOutput,”&yuml;”,”&#255;”)
strOutput = replace(strOutput,”&OElig;”,”&#338;”)
strOutput = replace(strOutput,”&oelig;”,”&#339;”)
strOutput = replace(strOutput,”&Scaron;”,”&#352;”)
strOutput = replace(strOutput,”&scaron;”,”&#353;”)
strOutput = replace(strOutput,”&Yuml;”,”&#376;”)
strOutput = replace(strOutput,”&circ;”,”&#710;”)
strOutput = replace(strOutput,”&tilde;”,”&#732;”)
strOutput = replace(strOutput,”&ensp;”,”&#8194;”)
strOutput = replace(strOutput,”&emsp;”,”&#8195;”)
strOutput = replace(strOutput,”&thinsp;”,”&#8201;”)
strOutput = replace(strOutput,”&zwnj;”,”&#8204;”)
strOutput = replace(strOutput,”&zwj;”,”&#8205;”)
strOutput = replace(strOutput,”&lrm;”,”&#8206;”)
strOutput = replace(strOutput,”&rlm;”,”&#8207;”)
strOutput = replace(strOutput,”&permil;”,”&#8240;”)
strOutput = replace(strOutput,”&lsaquo;”,”&#8249;”)
strOutput = replace(strOutput,”&rsaquo;”,”&#8250;”)
strOutput = replace(strOutput,”&euro;”,”&#8364;”)
    strOutput = Replace(strOutput, “ä”, “&#228;”)
    strOutput = Replace(strOutput, “Ä”, “&#196;”)
    strOutput = Replace(strOutput, “ö”, “&#246;”)
    strOutput = Replace(strOutput, “Ö”, “&#214;”)
    strOutput = Replace(strOutput, “ü”, “&#252;”)
    strOutput = Replace(strOutput, “Ü”, “&#220;”)
    strOutput = Replace(strOutput, “ß”, “&#223;”)

    htmlEntities = strOutput
END FUNCTION

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

Posted in misc.

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.