From: Thomas Jarosch Date: Mon, 29 Nov 2021 13:37:02 +0000 (+0100) Subject: Merge branch 'html_entities_iso' X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=4b497d721ebe04fc39e6df337600509542bcbfe0;hp=492f4a6dd23e5644d401ba9f16dadab1c4539efe;p=libi2ncommon Merge branch 'html_entities_iso' --- diff --git a/src/stringfunc.hxx b/src/stringfunc.hxx index d945526..06d85f9 100644 --- a/src/stringfunc.hxx +++ b/src/stringfunc.hxx @@ -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 CommentZone; std::vector find_html_comments(const std::string &str); void remove_html_comments(std::string &str); diff --git a/test/stringfunc.cpp b/test/stringfunc.cpp index 26cc0c8..6553632 100644 --- a/test/stringfunc.cpp +++ b/test/stringfunc.cpp @@ -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ä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ä"), 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 > Einstellungen"), output); } -BOOST_AUTO_TEST_CASE(smart_html_entites7) +BOOST_AUTO_TEST_CASE(smart_html_entities7) { string output = smart_html_entities("Finden Sie auf der Seite \"System > Einstellungen\". Oder etwa nicht?"); @@ -128,6 +128,12 @@ BOOST_AUTO_TEST_CASE(html_entities3) BOOST_CHECK_EQUAL(string("Ď ༱ 肈"), output); } +BOOST_AUTO_TEST_CASE(entities_latin1) +{ + BOOST_CHECK_EQUAL((std::string)"noop", html_entities_iso ("noop")); + BOOST_CHECK_EQUAL((std::string)"täst", html_entities_iso ("t\xe4st")); + BOOST_CHECK_EQUAL((std::string)"TÄST", html_entities_iso ("T\xc4ST")); +} BOOST_AUTO_TEST_CASE(nice_unit_format1)