StringUtil: Use unicode replacement character in DecodeUTF8()

This commit is contained in:
Stenzek 2024-08-25 13:56:01 +10:00
parent 096a0811bf
commit c8e61307b2
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);