bool TestExtString::test_htmlentities() { String str = "A 'quote' is <b>bold</b>"; VS(f_htmlentities(str), "A 'quote' is <b>bold</b>"); VS(f_htmlentities(str, k_ENT_QUOTES), "A 'quote' is <b>bold</b>"); VS(f_htmlentities("\xA0", k_ENT_COMPAT), " "); VS(f_htmlentities("\xc2\xA0", k_ENT_COMPAT, ""), " "); VS(f_htmlentities("\xc2\xA0", k_ENT_COMPAT, "UTF-8"), " "); return Count(true); }
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 "walk" the <b>dog</b> now"); VS(f_html_entity_decode(a), orig); VS(f_bin2hex(f_html_entity_decode(" ", 3)), "a0"); VS(f_bin2hex(f_html_entity_decode(" ", 3, "")), "c2a0"); VS(f_bin2hex(f_html_entity_decode(" ", 3, "UTF-8")), "c2a0"); VS(f_html_entity_decode("& & &", k_ENT_QUOTES, "UTF-8"), "& & &"); VS(f_bin2hex(f_html_entity_decode("È")), "c8"); VS(f_bin2hex(f_html_entity_decode("È", 3, "UTF-8")), "c388"); VS(f_html_entity_decode("Α"), "Α"); VS(f_bin2hex(f_html_entity_decode("Α", 3, "UTF-8")), "ce91"); return Count(true); }