1
0
Fork 0

Inline `String::utf8` and `String::utf16` for their simplicity.

This commit is contained in:
Lukas Tenbrink 2025-01-09 17:13:06 +01:00
parent eb4a9977c3
commit 33a34fe670
2 changed files with 10 additions and 16 deletions

View File

@ -1954,13 +1954,6 @@ CharString String::ascii(bool p_allow_extended) const {
return cs;
}
String String::utf8(const char *p_utf8, int p_len) {
String ret;
ret.parse_utf8(p_utf8, p_len);
return ret;
}
Error String::parse_utf8(const char *p_utf8, int p_len, bool p_skip_cr) {
if (!p_utf8) {
return ERR_INVALID_DATA;
@ -2225,13 +2218,6 @@ CharString String::utf8() const {
return utf8s;
}
String String::utf16(const char16_t *p_utf16, int p_len) {
String ret;
ret.parse_utf16(p_utf16, p_len, true);
return ret;
}
Error String::parse_utf16(const char16_t *p_utf16, int p_len, bool p_default_little_endian) {
if (!p_utf16) {
return ERR_INVALID_DATA;

View File

@ -523,11 +523,19 @@ public:
CharString ascii(bool p_allow_extended = false) const;
CharString utf8() const;
Error parse_utf8(const char *p_utf8, int p_len = -1, bool p_skip_cr = false);
static String utf8(const char *p_utf8, int p_len = -1);
static String utf8(const char *p_utf8, int p_len = -1) {
String ret;
ret.parse_utf8(p_utf8, p_len);
return ret;
}
Char16String utf16() const;
Error parse_utf16(const char16_t *p_utf16, int p_len = -1, bool p_default_little_endian = true);
static String utf16(const char16_t *p_utf16, int p_len = -1);
static String utf16(const char16_t *p_utf16, int p_len = -1) {
String ret;
ret.parse_utf16(p_utf16, p_len, true);
return ret;
}
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 */