title: Convert Special Characters to HTML - ColdFusion
body: <p>I need to convert a lot of special characters to their html format and I am trying to do this with a function that is using <code>ReplaceList</code> but something is wrong with the function or the values I am passing to it.</p>
  
  <p>This is the function</p>
  
  <pre><code>&lt;cffunction name="HtmlUnEditFormat" access="public" returntype="string" output="no" displayname="HtmlUnEditFormat" hint="Undo escaped characters"&gt;
      &lt;cfargument name="str" type="string" required="Yes" /&gt;
      &lt;cfscript&gt;
          var lEntities = "&amp;##xE7;,&amp;##xF4;,&amp;##xE2;,&amp;Icirc;,&amp;Ccedil;,&amp;Egrave;,&amp;Oacute;,&amp;Ecirc;,&amp;OElig,&amp;Acirc;,&amp;laquo;,&amp;raquo;,&amp;Agrave;,&amp;Eacute;,&amp;le;,&amp;yacute;,&amp;chi;,&amp;sum;,&amp;prime;,&amp;yuml;,&amp;sim;,&amp;beta;,&amp;lceil;,&amp;ntilde;,&amp;szlig;,&amp;bdquo;,&amp;acute;,&amp;middot;,&amp;ndash;,&amp;sigmaf;,&amp;reg;,&amp;dagger;,&amp;oplus;,&amp;otilde;,&amp;eta;,&amp;rceil;,&amp;oacute;,&amp;shy;,&amp;gt;,&amp;phi;,&amp;ang;,&amp;rlm;,&amp;alpha;,&amp;cap;,&amp;darr;,&amp;upsilon;,&amp;image;,&amp;sup3;,&amp;rho;,&amp;eacute;,&amp;sup1;,&amp;lt;,&amp;cent;,&amp;cedil;,&amp;pi;,&amp;sup;,&amp;divide;,&amp;fnof;,&amp;iquest;,&amp;ecirc;,&amp;ensp;,&amp;empty;,&amp;forall;,&amp;emsp;,&amp;gamma;,&amp;iexcl;,&amp;oslash;,&amp;not;,&amp;agrave;,&amp;eth;,&amp;alefsym;,&amp;ordm;,&amp;psi;,&amp;otimes;,&amp;delta;,&amp;ouml;,&amp;deg;,&amp;cong;,&amp;ordf;,&amp;lsaquo;,&amp;clubs;,&amp;acirc;,&amp;ograve;,&amp;iuml;,&amp;diams;,&amp;aelig;,&amp;and;,&amp;loz;,&amp;egrave;,&amp;frac34;,&amp;amp;,&amp;nsub;,&amp;nu;,&amp;ldquo;,&amp;isin;,&amp;ccedil;,&amp;circ;,&amp;copy;,&amp;aacute;,&amp;sect;,&amp;mdash;,&amp;euml;,&amp;kappa;,&amp;notin;,&amp;lfloor;,&amp;ge;,&amp;igrave;,&amp;harr;,&amp;lowast;,&amp;ocirc;,&amp;infin;,&amp;brvbar;,&amp;int;,&amp;macr;,&amp;frac12;,&amp;curren;,&amp;asymp;,&amp;lambda;,&amp;frasl;,&amp;lsquo;,&amp;hellip;,&amp;oelig;,&amp;pound;,&amp;hearts;,&amp;minus;,&amp;atilde;,&amp;epsilon;,&amp;nabla;,&amp;exist;,&amp;auml;,&amp;mu;,&amp;frac14;,&amp;nbsp;,&amp;equiv;,&amp;bull;,&amp;larr;,&amp;laquo;,&amp;oline;,&amp;or;,&amp;euro;,&amp;micro;,&amp;ne;,&amp;cup;,&amp;aring;,&amp;iota;,&amp;iacute;,&amp;perp;,&amp;para;,&amp;rarr;,&amp;raquo;,&amp;ucirc;,&amp;omicron;,&amp;sbquo;,&amp;thetasym;,&amp;ni;,&amp;part;,&amp;rdquo;,&amp;weierp;,&amp;permil;,&amp;sup2;,&amp;sigma;,&amp;sdot;,&amp;scaron;,&amp;yen;,&amp;xi;,&amp;plusmn;,&amp;real;,&amp;thorn;,&amp;rang;,&amp;ugrave;,&amp;radic;,&amp;zwj;,&amp;there4;,&amp;uarr;,&amp;times;,&amp;thinsp;,&amp;theta;,&amp;rfloor;,&amp;sub;,&amp;supe;,&amp;uuml;,&amp;rsquo;,&amp;zeta;,&amp;trade;,&amp;icirc;,&amp;piv;,&amp;zwnj;,&amp;lang;,&amp;tilde;,&amp;uacute;,&amp;uml;,&amp;prop;,&amp;upsih;,&amp;omega;,&amp;crarr;,&amp;tau;,&amp;sube;,&amp;rsaquo;,&amp;prod;,&amp;quot;,&amp;lrm;,&amp;spades;";
          var lEntitiesChars = "ç,ô,â,Î,Ç,È,Ó,Ê,Œ,Â,«,»,À,É,?,ý,?,?,?,Ÿ,?,?,?,ñ,ß,„,´,·,–,?,®,‡,?,õ,?,?,ó,­,&gt;,?,?,?,?,?,?,?,?,³,?,é,¹,&lt;,¢,¸,?,?,÷,ƒ,¿,ê,?,?,?,?,?,¡,ø,¬,à,ð,?,º,?,?,?,ö,°,?,ª,‹,?,â,ò,ï,?,æ,?,?,è,¾,&amp;,?,?,“,?,ç,ˆ,©,á,§,—,ë,?,?,?,?,ì,?,?,ô,?,¦,?,¯,½,¤,?,?,?,‘,…,œ,£,?,?,ã,?,?,?,ä,?,¼, ,?,•,?,«,?,?,€,µ,?,?,å,?,í,?,¶,?,»,û,?,‚,?,?,?,”,?,‰,²,?,?,š,¥,?,±,?,þ,?,ù,?,?,?,?,×,?,?,?,?,?,ü,’,?,™,î,?,?,?,˜,ú,¨,?,?,?,?,?,?,›,?,"",?,?";
      &lt;/cfscript&gt;
      &lt;cfreturn ReplaceList(arguments.str, lEntities, lEntitiesChars) /&gt;
  &lt;/cffunction&gt;
  </code></pre>
  
  <p>This is how I am calling it:</p>
  
  <pre><code>&lt;cfoutput&gt;
      &lt;cfloop query="local.q" startrow="2"&gt;
         #HtmlUnEditFormat(consultServiceType)# &lt;br /&gt;
      &lt;/cfloop&gt;
  &lt;/cfoutput&gt;
  </code></pre>
  
  <p>These are the strings I am passing to it:</p>
  
  <pre><code>Security?
  Security Guard®
  Alarm System©
  Private Investigator;
  </code></pre>
  
  <p>I am not getting any errors back (I had a cftry in the function before) and the strings come back the same</p>
  
  <p>EDIT:</p>
  
  <p>I've tried using #FindNoCase('©',consultServiceType)# and is returning 0 so I guess something is wrong with the string I am passing in?</p>