diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 5e0eaa53cc..3608d1afc1 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -347,29 +347,6 @@ void String::parse_utf32(const Span &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 diff --git a/core/string/ustring.h b/core/string/ustring.h index f72685e704..fdac0d5d68 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -436,7 +436,7 @@ public: static String num_uint64(uint64_t p_num, int base = 10, bool capitalize_hex = false); static String chr(char32_t p_char) { String string; - string.parse_utf32(p_char); + string.parse_utf32(Span(&p_char, 1)); return string; } static String md5(const uint8_t *p_md5); @@ -540,7 +540,6 @@ public: static String utf16(const Span &p_range) { return utf16(p_range.ptr(), p_range.size()); } void parse_utf32(const Span &p_cstr); - void parse_utf32(const char32_t &p_char); static uint32_t hash(const char32_t *p_cstr, int p_len); /* hash the string */ static uint32_t hash(const char32_t *p_cstr); /* hash the string */