You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 19:31:35 +00:00
Deduplicate string::parse_utf32(char32_t) in favor of just using the Span based function.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<char16_t> &p_range) { return utf16(p_range.ptr(), p_range.size()); }
|
||||
|
||||
void parse_utf32(const Span<char32_t> &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 */
|
||||
|
||||
Reference in New Issue
Block a user