Skip to content

Commit

Permalink
charset: utf8_to_locale() returns std::string_view
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Aug 31, 2024
1 parent adeb34b commit 5404271
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/charset.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ CopyUtf8ToLocale(std::span<char> dest, const std::string_view src) noexcept
#endif
}

const char *
utf8_to_locale(const char *src, std::span<char> buffer) noexcept
std::string_view
utf8_to_locale(std::string_view src, std::span<char> buffer) noexcept
{
#ifdef HAVE_ICONV
CopyUtf8ToLocale(buffer, src);
return buffer.data();
char *end = CopyUtf8ToLocale(buffer, src);
return {buffer.data(), end};
#else
(void)buffer;
return src;
Expand Down
4 changes: 2 additions & 2 deletions src/charset.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ char *
CopyUtf8ToLocale(std::span<char> dest, std::string_view src) noexcept;

[[gnu::pure]]
const char *
utf8_to_locale(const char *src, std::span<char> buffer) noexcept;
std::string_view
utf8_to_locale(std::string_view src, std::span<char> buffer) noexcept;

/**
* Convert an UTF-8 string to the locale charset. The source string
Expand Down

0 comments on commit 5404271

Please sign in to comment.