From 5404271ddeca1c8186940a86fba197c1bde61c79 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 31 Aug 2024 22:48:44 +0200 Subject: [PATCH] charset: utf8_to_locale() returns std::string_view --- src/charset.cxx | 8 ++++---- src/charset.hxx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/charset.cxx b/src/charset.cxx index 53b57d9d..4293d8f6 100644 --- a/src/charset.cxx +++ b/src/charset.cxx @@ -194,12 +194,12 @@ CopyUtf8ToLocale(std::span dest, const std::string_view src) noexcept #endif } -const char * -utf8_to_locale(const char *src, std::span buffer) noexcept +std::string_view +utf8_to_locale(std::string_view src, std::span 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; diff --git a/src/charset.hxx b/src/charset.hxx index e836c34a..b3ff0333 100644 --- a/src/charset.hxx +++ b/src/charset.hxx @@ -20,8 +20,8 @@ char * CopyUtf8ToLocale(std::span dest, std::string_view src) noexcept; [[gnu::pure]] -const char * -utf8_to_locale(const char *src, std::span buffer) noexcept; +std::string_view +utf8_to_locale(std::string_view src, std::span buffer) noexcept; /** * Convert an UTF-8 string to the locale charset. The source string