Add GDScript to_wchar_buffer and get_string_from_wchar functions.
This commit is contained in:
@ -5034,6 +5034,14 @@ Vector<uint8_t> String::to_utf32_buffer() const {
|
||||
return retval;
|
||||
}
|
||||
|
||||
Vector<uint8_t> String::to_wchar_buffer() const {
|
||||
#ifdef WINDOWS_ENABLED
|
||||
return to_utf16_buffer();
|
||||
#else
|
||||
return to_utf32_buffer();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
/**
|
||||
* "Tools TRanslate". Performs string replacement for internationalization
|
||||
|
||||
@ -455,6 +455,7 @@ public:
|
||||
Vector<uint8_t> to_utf8_buffer() const;
|
||||
Vector<uint8_t> to_utf16_buffer() const;
|
||||
Vector<uint8_t> to_utf32_buffer() const;
|
||||
Vector<uint8_t> to_wchar_buffer() const;
|
||||
|
||||
String(const char *p_str);
|
||||
String(const wchar_t *p_str);
|
||||
|
||||
@ -700,6 +700,19 @@ struct _VariantCall {
|
||||
return s;
|
||||
}
|
||||
|
||||
static String func_PackedByteArray_get_string_from_wchar(PackedByteArray *p_instance) {
|
||||
String s;
|
||||
if (p_instance->size() > 0) {
|
||||
const uint8_t *r = p_instance->ptr();
|
||||
#ifdef WINDOWS_ENABLED
|
||||
s.parse_utf16((const char16_t *)r, floor((double)p_instance->size() / (double)sizeof(char16_t)));
|
||||
#else
|
||||
s = String((const char32_t *)r, floor((double)p_instance->size() / (double)sizeof(char32_t)));
|
||||
#endif
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
static PackedByteArray func_PackedByteArray_compress(PackedByteArray *p_instance, int p_mode) {
|
||||
PackedByteArray compressed;
|
||||
|
||||
@ -1721,6 +1734,7 @@ static void _register_variant_builtin_methods() {
|
||||
bind_string_method(to_utf8_buffer, sarray(), varray());
|
||||
bind_string_method(to_utf16_buffer, sarray(), varray());
|
||||
bind_string_method(to_utf32_buffer, sarray(), varray());
|
||||
bind_string_method(to_wchar_buffer, sarray(), varray());
|
||||
|
||||
bind_static_method(String, num_scientific, sarray("number"), varray());
|
||||
bind_static_method(String, num, sarray("number", "decimals"), varray(-1));
|
||||
@ -2258,6 +2272,7 @@ static void _register_variant_builtin_methods() {
|
||||
bind_function(PackedByteArray, get_string_from_utf8, _VariantCall::func_PackedByteArray_get_string_from_utf8, sarray(), varray());
|
||||
bind_function(PackedByteArray, get_string_from_utf16, _VariantCall::func_PackedByteArray_get_string_from_utf16, sarray(), varray());
|
||||
bind_function(PackedByteArray, get_string_from_utf32, _VariantCall::func_PackedByteArray_get_string_from_utf32, sarray(), varray());
|
||||
bind_function(PackedByteArray, get_string_from_wchar, _VariantCall::func_PackedByteArray_get_string_from_wchar, sarray(), varray());
|
||||
bind_function(PackedByteArray, hex_encode, _VariantCall::func_PackedByteArray_hex_encode, sarray(), varray());
|
||||
bind_function(PackedByteArray, compress, _VariantCall::func_PackedByteArray_compress, sarray("compression_mode"), varray(0));
|
||||
bind_function(PackedByteArray, decompress, _VariantCall::func_PackedByteArray_decompress, sarray("buffer_size", "compression_mode"), varray(0));
|
||||
|
||||
Reference in New Issue
Block a user