From 54136057d82a6076248289d47db1e23eed8eed7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano?= Date: Fri, 3 Mar 2023 12:46:26 +0900 Subject: [PATCH] Remove the old UTF-8 conversion routines --- src/opustags.h | 2 -- src/system.cc | 15 ++------------- t/system.cc | 5 +---- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/opustags.h b/src/opustags.h index a97479e..47775cf 100644 --- a/src/opustags.h +++ b/src/opustags.h @@ -162,11 +162,9 @@ byte_string slurp_binary_file(const char* filename); /** Convert a string from the system locale’s encoding to UTF-8. */ std::u8string encode_utf8(std::string_view); -std::string to_utf8(std::string_view); ///< \deprecated /** Convert a string from UTF-8 to the system locale’s encoding. */ std::string decode_utf8(std::u8string_view); -std::string from_utf8(std::string_view); ///< \deprecated /** Escape a string so that a POSIX shell interprets it as a single argument. */ std::string shell_escape(std::string_view word); diff --git a/src/system.cc b/src/system.cc index 431e040..a93acd3 100644 --- a/src/system.cc +++ b/src/system.cc @@ -210,29 +210,18 @@ std::basic_string encoding_converter::convert(std::basic_string_view(in); } -std::string ot::to_utf8(std::string_view in) -{ - return to_utf8_cvt.convert(in); -} - std::string ot::decode_utf8(std::u8string_view in) { + static encoding_converter from_utf8_cvt("UTF-8", ""); return from_utf8_cvt.convert(in); } -std::string ot::from_utf8(std::string_view in) -{ - return from_utf8_cvt.convert(in); -} - std::string ot::shell_escape(std::string_view word) { std::string escaped_word; diff --git a/t/system.cc b/t/system.cc index c8deae7..c5fb89b 100644 --- a/t/system.cc +++ b/t/system.cc @@ -48,15 +48,12 @@ void check_slurp() void check_converter() { - is(ot::from_utf8(ot::to_utf8("Éphémère")), "Éphémère", "from_utf8 reverts to_utf8"); - is(ot::to_utf8(ot::from_utf8("Éphémère")), "Éphémère", "to_utf8 reverts from_utf8"); - is(ot::decode_utf8(ot::encode_utf8("Éphémère")), "Éphémère", "decode_utf8 reverts encode_utf8"); opaque_is(ot::encode_utf8(ot::decode_utf8(u8"Éphémère")), u8"Éphémère", "encode_utf8 reverts decode_utf8"); try { - ot::from_utf8("\xFF\xFF"); + ot::decode_utf8((char8_t*) "\xFF\xFF"); throw failure("conversion from bad UTF-8 did not fail"); } catch (const ot::status&) {} }