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().

This commit is contained in:
Relintai 2023-03-20 22:34:21 +01:00
parent a0d33b5fcd
commit 4b23c9c5c9
3 changed files with 8 additions and 8 deletions

View File

@ -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;

View File

@ -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 */

View File

@ -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());