From: Philipp Gesang Date: Mon, 29 Nov 2021 13:24:10 +0000 (+0100) Subject: add latin-1 wrapper for html_entities X-Git-Url: http://developer.intra2net.com/git/?p=libi2ncommon;a=commitdiff_plain;h=dfc070292e1d577b5ec19f1e36324e60520b3022 add latin-1 wrapper for html_entities Still a bit underwhelming as we can't express the encoding difference in the type system. --- 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..90bd63a 100644 --- a/test/stringfunc.cpp +++ b/test/stringfunc.cpp @@ -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)