From 4b23c9c5c9ea5758af34c6cca10f06bffef4c22e Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 20 Mar 2023 22:34:21 +0100 Subject: [PATCH] Renamed utf8_length() to utf8_byte_length(), and utf16_length() to utf16_byte_length() in String, as this might help to better explain why these differ from normal length(). --- core/string/ustring.cpp | 4 ++-- core/string/ustring.h | 4 ++-- core/variant/variant_call.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 5f069e744..e73b02c3a 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -3381,7 +3381,7 @@ CharString String::utf8() const { return utf8s; } -int String::utf8_length() const { +int String::utf8_byte_length() const { int l = length(); if (!l) { return 0; @@ -3587,7 +3587,7 @@ Char16String String::utf16() const { return utf16s; } -int String::utf16_length() const { +int String::utf16_byte_length() const { int l = length(); if (!l) { return 0; diff --git a/core/string/ustring.h b/core/string/ustring.h index 375fd26e6..0feceee7a 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -436,12 +436,12 @@ public: CharString utf8() const; Error parse_utf8(const char *p_utf8, int p_len = -1, bool p_skip_cr = false); //return true on error static String utf8(const char *p_utf8, int p_len = -1); - int utf8_length() const; + int utf8_byte_length() const; Char16String utf16() const; Error parse_utf16(const char16_t *p_utf16, int p_len = -1); static String utf16(const char16_t *p_utf16, int p_len = -1); - int utf16_length() const; + int utf16_byte_length() const; static uint32_t hash(const char *p_cstr); /* hash the string */ static uint32_t hash(const char *p_cstr, int p_len); /* hash the string */ diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index d680f0b19..af11fb65b 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -377,8 +377,8 @@ struct _VariantCall { VCALL_LOCALMEM1R(String, unicode_at); VCALL_LOCALMEM1R(String, ord_at); VCALL_LOCALMEM2(String, erase); - VCALL_LOCALMEM0R(String, utf8_length); - VCALL_LOCALMEM0R(String, utf16_length); + VCALL_LOCALMEM0R(String, utf8_byte_length); + VCALL_LOCALMEM0R(String, utf16_byte_length); VCALL_LOCALMEM0R(String, hash); VCALL_LOCALMEM0R(String, md5_text); VCALL_LOCALMEM0R(String, sha1_text); @@ -2555,8 +2555,8 @@ void register_variant_methods() { ADDFUNC2(STRING, NIL, String, erase, INT, "position", INT, "chars", varray()); - ADDFUNC0R(STRING, INT, String, utf8_length, varray()); - ADDFUNC0R(STRING, INT, String, utf16_length, varray()); + ADDFUNC0R(STRING, INT, String, utf8_byte_length, varray()); + ADDFUNC0R(STRING, INT, String, utf16_byte_length, varray()); ADDFUNC0R(STRING, INT, String, hash, varray()); ADDFUNC0R(STRING, STRING, String, md5_text, varray());