Merge branch 'html_entities_iso'
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 29 Nov 2021 13:37:02 +0000 (14:37 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 29 Nov 2021 13:37:02 +0000 (14:37 +0100)
src/stringfunc.hxx
test/stringfunc.cpp

index d945526..06d85f9 100644 (file)
@@ -358,6 +358,11 @@ std::string smart_html_entities(const std::string &input);
 std::string html_entities(std::string str);
 std::string html_entities_to_console(std::string str);
 
+inline std::string html_entities_iso (const std::string &str)
+{
+    return html_entities (iso_to_utf8 (str));
+}
+
 typedef std::pair<std::string::size_type, std::string::size_type> CommentZone;
 std::vector<CommentZone> find_html_comments(const std::string &str);
 void remove_html_comments(std::string &str);
index 26cc0c8..6553632 100644 (file)
@@ -45,49 +45,49 @@ typedef std::list< std::string > StringList;
 
 BOOST_AUTO_TEST_SUITE(stringfunc)
 
-BOOST_AUTO_TEST_CASE(smart_html_entites1)
+BOOST_AUTO_TEST_CASE(smart_html_entities1)
 {
     string output = smart_html_entities("Test");
 
     BOOST_CHECK_EQUAL(string("Test"), output);
 }
 
-BOOST_AUTO_TEST_CASE(smart_html_entites2)
+BOOST_AUTO_TEST_CASE(smart_html_entities2)
 {
     string output = smart_html_entities("Täst");
 
     BOOST_CHECK_EQUAL(string("T&auml;st"), output);
 }
 
-BOOST_AUTO_TEST_CASE(smart_html_entites3)
+BOOST_AUTO_TEST_CASE(smart_html_entities3)
 {
     string output = smart_html_entities("<>");
 
     BOOST_CHECK_EQUAL(string("<>"), output);
 }
 
-BOOST_AUTO_TEST_CASE(smart_html_entites4)
+BOOST_AUTO_TEST_CASE(smart_html_entities4)
 {
     string output = smart_html_entities("<ümlaut>");
 
     BOOST_CHECK_EQUAL(string("<ümlaut>"), output);
 }
 
-BOOST_AUTO_TEST_CASE(smart_html_entites5)
+BOOST_AUTO_TEST_CASE(smart_html_entities5)
 {
     string output = smart_html_entities("Test<ümlaut>Blä");
 
     BOOST_CHECK_EQUAL(string("Test<ümlaut>Bl&auml;"), output);
 }
 
-BOOST_AUTO_TEST_CASE(smart_html_entites6)
+BOOST_AUTO_TEST_CASE(smart_html_entities6)
 {
     string output = smart_html_entities("System > Einstellungen");
 
     BOOST_CHECK_EQUAL(string("System &gt; Einstellungen"), output);
 }
 
-BOOST_AUTO_TEST_CASE(smart_html_entites7)
+BOOST_AUTO_TEST_CASE(smart_html_entities7)
 {
     string output = smart_html_entities("Finden Sie <b>auf</b> der Seite <a href=\"fdslfsl\">\"System > Einstellungen\"</a>. Oder etwa nicht?");
 
@@ -128,6 +128,12 @@ BOOST_AUTO_TEST_CASE(html_entities3)
     BOOST_CHECK_EQUAL(string("&#270; &#3889; &#32904;"), output);
 }
 
+BOOST_AUTO_TEST_CASE(entities_latin1)
+{
+    BOOST_CHECK_EQUAL((std::string)"noop", html_entities_iso ("noop"));
+    BOOST_CHECK_EQUAL((std::string)"t&auml;st", html_entities_iso ("t\xe4st"));
+    BOOST_CHECK_EQUAL((std::string)"T&Auml;ST", html_entities_iso ("T\xc4ST"));
+}
 
 
 BOOST_AUTO_TEST_CASE(nice_unit_format1)