StringUtil: Use unicode replacement character in DecodeUTF8()

This commit is contained in:
Stenzek 2024-08-25 13:56:01 +10:00
parent b7a2b0b265
commit 3ed3b5a076
No known key found for this signature in database
2 changed files with 4 additions and 1 deletions

View file

@ -388,7 +388,7 @@ size_t StringUtil::DecodeUTF8(const void* bytes, size_t length, char32_t* ch)
}
invalid:
*ch = 0xFFFFFFFFu;
*ch = UNICODE_REPLACEMENT_CHARACTER; // unicode replacement character
return 1;
}

View file

@ -263,6 +263,9 @@ void ReplaceAll(std::string* subject, const char search, const char replacement)
/// Parses an assignment string (Key = Value) into its two components.
bool ParseAssignmentString(const std::string_view str, std::string_view* key, std::string_view* value);
/// Unicode replacement character.
static constexpr char32_t UNICODE_REPLACEMENT_CHARACTER = 0xFFFD;
/// Appends a UTF-16/UTF-32 codepoint to a UTF-8 string.
void EncodeAndAppendUTF8(std::string& s, char32_t ch);