mirror of
https://github.com/fmang/opustags.git
synced 2025-01-15 12:43:17 +01:00
Remove the old UTF-8 conversion routines
This commit is contained in:
parent
1d13c258e4
commit
54136057d8
@ -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);
|
||||
|
@ -210,29 +210,18 @@ std::basic_string<OutChar> encoding_converter::convert(std::basic_string_view<In
|
||||
return out;
|
||||
}
|
||||
|
||||
static encoding_converter to_utf8_cvt("", "UTF-8");
|
||||
static encoding_converter from_utf8_cvt("UTF-8", "");
|
||||
|
||||
std::u8string ot::encode_utf8(std::string_view in)
|
||||
{
|
||||
static encoding_converter to_utf8_cvt("", "UTF-8");
|
||||
return to_utf8_cvt.convert<char, char8_t>(in);
|
||||
}
|
||||
|
||||
std::string ot::to_utf8(std::string_view in)
|
||||
{
|
||||
return to_utf8_cvt.convert<char, char>(in);
|
||||
}
|
||||
|
||||
std::string ot::decode_utf8(std::u8string_view in)
|
||||
{
|
||||
static encoding_converter from_utf8_cvt("UTF-8", "");
|
||||
return from_utf8_cvt.convert<char8_t, char>(in);
|
||||
}
|
||||
|
||||
std::string ot::from_utf8(std::string_view in)
|
||||
{
|
||||
return from_utf8_cvt.convert<char, char>(in);
|
||||
}
|
||||
|
||||
std::string ot::shell_escape(std::string_view word)
|
||||
{
|
||||
std::string escaped_word;
|
||||
|
@ -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&) {}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user