#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "base/strings/utf_string_conversion_utils.h"
#include "base/third_party/icu/icu_utf.h"
#include "build/build_config.h"
namespace base {
std::optional<size_t> CountUnicodeCharacters(std::string_view text,
size_t limit) { … }
bool ReadUnicodeCharacter(const char* src,
size_t src_len,
size_t* char_index,
base_icu::UChar32* code_point_out) { … }
bool ReadUnicodeCharacter(const char16_t* src,
size_t src_len,
size_t* char_index,
base_icu::UChar32* code_point) { … }
#if defined(WCHAR_T_IS_32_BIT)
bool ReadUnicodeCharacter(const wchar_t* src,
size_t src_len,
size_t* char_index,
base_icu::UChar32* code_point) { … }
#endif
size_t WriteUnicodeCharacter(base_icu::UChar32 code_point,
std::string* output) { … }
size_t WriteUnicodeCharacter(base_icu::UChar32 code_point,
std::u16string* output) { … }
template<typename CHAR>
void PrepareForUTF8Output(const CHAR* src,
size_t src_len,
std::string* output) { … }
#if !BUILDFLAG(IS_WIN)
template void PrepareForUTF8Output(const wchar_t*, size_t, std::string*);
#endif
template void PrepareForUTF8Output(const char16_t*, size_t, std::string*);
template<typename STRING>
void PrepareForUTF16Or32Output(const char* src,
size_t src_len,
STRING* output) { … }
#if !BUILDFLAG(IS_WIN)
template void PrepareForUTF16Or32Output(const char*, size_t, std::wstring*);
#endif
template void PrepareForUTF16Or32Output(const char*, size_t, std::u16string*);
}