Exemplo n.º 1
0
bool TestExtString::test_htmlentities() {
  String str = "A 'quote' is <b>bold</b>";
  VS(f_htmlentities(str), "A 'quote' is &lt;b&gt;bold&lt;/b&gt;");
  VS(f_htmlentities(str, k_ENT_QUOTES),
     "A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;");

  VS(f_htmlentities("\xA0", k_ENT_COMPAT), "&nbsp;");
  VS(f_htmlentities("\xc2\xA0", k_ENT_COMPAT, ""), "&nbsp;");
  VS(f_htmlentities("\xc2\xA0", k_ENT_COMPAT, "UTF-8"), "&nbsp;");

  return Count(true);
}
Exemplo n.º 2
0
bool TestExtString::test_html_entity_decode() {
  String orig = "I'll \"walk\" the <b>dog</b> now";
  String a = f_htmlentities(orig);
  VS(a, "I'll &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; now");
  VS(f_html_entity_decode(a), orig);

  VS(f_bin2hex(f_html_entity_decode("&nbsp;", 3)), "a0");
  VS(f_bin2hex(f_html_entity_decode("&nbsp;", 3, "")), "c2a0");
  VS(f_bin2hex(f_html_entity_decode("&nbsp;", 3, "UTF-8")), "c2a0");

  VS(f_html_entity_decode("&amp; & &amp;", k_ENT_QUOTES, "UTF-8"), "& & &");

  VS(f_bin2hex(f_html_entity_decode("&Egrave;")), "c8");
  VS(f_bin2hex(f_html_entity_decode("&Egrave;", 3, "UTF-8")), "c388");

  VS(f_html_entity_decode("&Alpha;"), "&Alpha;");
  VS(f_bin2hex(f_html_entity_decode("&Alpha;", 3, "UTF-8")), "ce91");
  return Count(true);
}