Deduplicate string::parse_utf32(char32_t) in favor of just using the Span based function.

This commit is contained in:
Lukas Tenbrink
2025-03-12 19:30:00 +01:00
parent 701505eb4f
commit 626ff950fb
2 changed files with 1 additions and 25 deletions

View File

@@ -347,29 +347,6 @@ void String::parse_utf32(const Span<char32_t> &p_cstr) {
*dst = 0;
}
void String::parse_utf32(const char32_t &p_char) {
if (p_char == 0) {
print_unicode_error("NUL character", true);
return;
}
resize(2);
char32_t *dst = ptrw();
if ((p_char & 0xfffff800) == 0xd800) {
print_unicode_error(vformat("Unpaired surrogate (%x)", (uint32_t)p_char));
dst[0] = _replacement_char;
} else if (p_char > 0x10ffff) {
print_unicode_error(vformat("Invalid unicode codepoint (%x)", (uint32_t)p_char));
dst[0] = _replacement_char;
} else {
dst[0] = p_char;
}
dst[1] = 0;
}
// assumes the following have already been validated:
// p_char != nullptr
// p_length > 0