Add methods to decode/encode multibyte encodings.

This commit is contained in:
bruvzg 2024-09-13 09:19:26 +03:00 committed by Pāvels Nadtočajevs
parent b13c96b097
commit 48bfe13e4f
No known key found for this signature in database
GPG key ID: 8413210218EF35D2
12 changed files with 420 additions and 1 deletions

View file

@ -34,6 +34,8 @@
#include "core/math/color.h"
#include "core/math/math_funcs.h"
#include "core/object/object.h"
#include "core/os/memory.h"
#include "core/os/os.h"
#include "core/string/print_string.h"
#include "core/string/string_name.h"
#include "core/string/translation_server.h"
@ -5987,6 +5989,10 @@ Vector<uint8_t> String::to_wchar_buffer() const {
#endif
}
Vector<uint8_t> String::to_multibyte_char_buffer(const String &p_encoding) const {
return OS::get_singleton()->string_to_multibyte(p_encoding, *this);
}
#ifdef TOOLS_ENABLED
/**
* "Tools TRanslate". Performs string replacement for internationalization

View file

@ -618,6 +618,7 @@ public:
Vector<uint8_t> to_utf16_buffer() const;
Vector<uint8_t> to_utf32_buffer() const;
Vector<uint8_t> to_wchar_buffer() const;
Vector<uint8_t> to_multibyte_char_buffer(const String &p_encoding = String()) const;
// Constructors for NULL terminated C strings.
String(const char *p_cstr) {