Merge pull request #104810 from kiroxas/utf8_cleanup
Replace `append_utfx` with direct `String::utfx`
This commit is contained in:
@@ -774,8 +774,7 @@ Error ProjectSettings::_load_settings_binary(const String &p_path) {
|
|||||||
cs.resize(slen + 1);
|
cs.resize(slen + 1);
|
||||||
cs[slen] = 0;
|
cs[slen] = 0;
|
||||||
f->get_buffer((uint8_t *)cs.ptr(), slen);
|
f->get_buffer((uint8_t *)cs.ptr(), slen);
|
||||||
String key;
|
String key = String::utf8(cs.ptr(), slen);
|
||||||
key.append_utf8(cs.ptr(), slen);
|
|
||||||
|
|
||||||
uint32_t vlen = f->get_32();
|
uint32_t vlen = f->get_32();
|
||||||
Vector<uint8_t> d;
|
Vector<uint8_t> d;
|
||||||
|
|||||||
@@ -1052,16 +1052,12 @@ static void gdextension_string_name_new_with_latin1_chars(GDExtensionUninitializ
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void gdextension_string_name_new_with_utf8_chars(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents) {
|
static void gdextension_string_name_new_with_utf8_chars(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents) {
|
||||||
String tmp;
|
String tmp = String::utf8(p_contents);
|
||||||
tmp.append_utf8(p_contents);
|
|
||||||
|
|
||||||
memnew_placement(r_dest, StringName(tmp));
|
memnew_placement(r_dest, StringName(tmp));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gdextension_string_name_new_with_utf8_chars_and_len(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents, GDExtensionInt p_size) {
|
static void gdextension_string_name_new_with_utf8_chars_and_len(GDExtensionUninitializedStringNamePtr r_dest, const char *p_contents, GDExtensionInt p_size) {
|
||||||
String tmp;
|
String tmp = String::utf8(p_contents, p_size);
|
||||||
tmp.append_utf8(p_contents, p_size);
|
|
||||||
|
|
||||||
memnew_placement(r_dest, StringName(tmp));
|
memnew_placement(r_dest, StringName(tmp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -744,9 +744,7 @@ String FileAccess::get_pascal_string() {
|
|||||||
get_buffer((uint8_t *)cs.ptr(), sl);
|
get_buffer((uint8_t *)cs.ptr(), sl);
|
||||||
cs[sl] = 0;
|
cs[sl] = 0;
|
||||||
|
|
||||||
String ret;
|
return String::utf8(cs.ptr(), sl);
|
||||||
ret.append_utf8(cs.ptr(), sl);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileAccess::store_line(const String &p_line) {
|
bool FileAccess::store_line(const String &p_line) {
|
||||||
|
|||||||
@@ -306,9 +306,7 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files,
|
|||||||
f->get_buffer((uint8_t *)cs.ptr(), sl);
|
f->get_buffer((uint8_t *)cs.ptr(), sl);
|
||||||
cs[sl] = 0;
|
cs[sl] = 0;
|
||||||
|
|
||||||
String path;
|
String path = String::utf8(cs.ptr(), sl);
|
||||||
path.append_utf8(cs.ptr(), sl);
|
|
||||||
|
|
||||||
uint64_t ofs = f->get_64();
|
uint64_t ofs = f->get_64();
|
||||||
uint64_t size = f->get_64();
|
uint64_t size = f->get_64();
|
||||||
uint8_t md5[16];
|
uint8_t md5[16];
|
||||||
|
|||||||
@@ -483,8 +483,7 @@ Error HTTPClientTCP::poll() {
|
|||||||
(rs >= 4 && response_str[rs - 4] == '\r' && response_str[rs - 3] == '\n' && response_str[rs - 2] == '\r' && response_str[rs - 1] == '\n')) {
|
(rs >= 4 && response_str[rs - 4] == '\r' && response_str[rs - 3] == '\n' && response_str[rs - 2] == '\r' && response_str[rs - 1] == '\n')) {
|
||||||
// End of response, parse.
|
// End of response, parse.
|
||||||
response_str.push_back(0);
|
response_str.push_back(0);
|
||||||
String response;
|
String response = String::utf8((const char *)response_str.ptr(), response_str.size());
|
||||||
response.append_utf8((const char *)response_str.ptr(), response_str.size());
|
|
||||||
Vector<String> responses = response.split("\n");
|
Vector<String> responses = response.split("\n");
|
||||||
body_size = -1;
|
body_size = -1;
|
||||||
chunked = false;
|
chunked = false;
|
||||||
|
|||||||
+1
-3
@@ -647,10 +647,8 @@ bool PList::load_file(const String &p_filename) {
|
|||||||
Vector<uint8_t> array = FileAccess::get_file_as_bytes(p_filename, &err);
|
Vector<uint8_t> array = FileAccess::get_file_as_bytes(p_filename, &err);
|
||||||
ERR_FAIL_COND_V(err != OK, false);
|
ERR_FAIL_COND_V(err != OK, false);
|
||||||
|
|
||||||
String ret;
|
|
||||||
ret.append_utf8((const char *)array.ptr(), array.size());
|
|
||||||
String err_str;
|
String err_str;
|
||||||
bool ok = load_string(ret, err_str);
|
bool ok = load_string(String::utf8((const char *)array.ptr(), array.size()), err_str);
|
||||||
ERR_FAIL_COND_V_MSG(!ok, false, "PList: " + err_str);
|
ERR_FAIL_COND_V_MSG(!ok, false, "PList: " + err_str);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -162,9 +162,7 @@ StringName ResourceLoaderBinary::_get_string() {
|
|||||||
return StringName();
|
return StringName();
|
||||||
}
|
}
|
||||||
f->get_buffer((uint8_t *)&str_buf[0], len);
|
f->get_buffer((uint8_t *)&str_buf[0], len);
|
||||||
String s;
|
return String::utf8(&str_buf[0], len);
|
||||||
s.append_utf8(&str_buf[0], len);
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return string_map[id];
|
return string_map[id];
|
||||||
@@ -918,9 +916,7 @@ static String get_ustring(Ref<FileAccess> f) {
|
|||||||
Vector<char> str_buf;
|
Vector<char> str_buf;
|
||||||
str_buf.resize(len);
|
str_buf.resize(len);
|
||||||
f->get_buffer((uint8_t *)&str_buf[0], len);
|
f->get_buffer((uint8_t *)&str_buf[0], len);
|
||||||
String s;
|
return String::utf8(&str_buf[0], len);
|
||||||
s.append_utf8(&str_buf[0], len);
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String ResourceLoaderBinary::get_unicode_string() {
|
String ResourceLoaderBinary::get_unicode_string() {
|
||||||
@@ -932,9 +928,7 @@ String ResourceLoaderBinary::get_unicode_string() {
|
|||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
f->get_buffer((uint8_t *)&str_buf[0], len);
|
f->get_buffer((uint8_t *)&str_buf[0], len);
|
||||||
String s;
|
return String::utf8(&str_buf[0], len);
|
||||||
s.append_utf8(&str_buf[0], len);
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceLoaderBinary::get_classes_used(Ref<FileAccess> p_f, HashSet<StringName> *p_classes) {
|
void ResourceLoaderBinary::get_classes_used(Ref<FileAccess> p_f, HashSet<StringName> *p_classes) {
|
||||||
|
|||||||
@@ -383,9 +383,7 @@ String StreamPeer::get_utf8_string(int p_bytes) {
|
|||||||
err = get_data(buf.ptrw(), p_bytes);
|
err = get_data(buf.ptrw(), p_bytes);
|
||||||
ERR_FAIL_COND_V(err != OK, String());
|
ERR_FAIL_COND_V(err != OK, String());
|
||||||
|
|
||||||
String ret;
|
return String::utf8((const char *)buf.ptr(), buf.size());
|
||||||
ret.append_utf8((const char *)buf.ptr(), buf.size());
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant StreamPeer::get_var(bool p_allow_objects) {
|
Variant StreamPeer::get_var(bool p_allow_objects) {
|
||||||
|
|||||||
+1
-2
@@ -76,8 +76,7 @@ void *zipio_open(voidpf opaque, const char *p_fname, int mode) {
|
|||||||
Ref<FileAccess> *fa = reinterpret_cast<Ref<FileAccess> *>(opaque);
|
Ref<FileAccess> *fa = reinterpret_cast<Ref<FileAccess> *>(opaque);
|
||||||
ERR_FAIL_NULL_V(fa, nullptr);
|
ERR_FAIL_NULL_V(fa, nullptr);
|
||||||
|
|
||||||
String fname;
|
String fname = String::utf8(p_fname);
|
||||||
fname.append_utf8(p_fname);
|
|
||||||
|
|
||||||
int file_access_mode = 0;
|
int file_access_mode = 0;
|
||||||
if (mode & ZLIB_FILEFUNC_MODE_READ) {
|
if (mode & ZLIB_FILEFUNC_MODE_READ) {
|
||||||
|
|||||||
@@ -253,17 +253,12 @@ StringName OptimizedTranslation::get_message(const StringName &p_src_text, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bucket.elem[idx].comp_size == bucket.elem[idx].uncomp_size) {
|
if (bucket.elem[idx].comp_size == bucket.elem[idx].uncomp_size) {
|
||||||
String rstr;
|
return String::utf8(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].uncomp_size);
|
||||||
rstr.append_utf8(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].uncomp_size);
|
|
||||||
|
|
||||||
return rstr;
|
|
||||||
} else {
|
} else {
|
||||||
CharString uncomp;
|
CharString uncomp;
|
||||||
uncomp.resize(bucket.elem[idx].uncomp_size + 1);
|
uncomp.resize(bucket.elem[idx].uncomp_size + 1);
|
||||||
smaz_decompress(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].comp_size, uncomp.ptrw(), bucket.elem[idx].uncomp_size);
|
smaz_decompress(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].comp_size, uncomp.ptrw(), bucket.elem[idx].uncomp_size);
|
||||||
String rstr;
|
return String::utf8(uncomp.get_data());
|
||||||
rstr.append_utf8(uncomp.get_data());
|
|
||||||
return rstr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,15 +278,13 @@ Vector<String> OptimizedTranslation::get_translated_message_list() const {
|
|||||||
const Bucket &bucket = *(const Bucket *)&btptr[p];
|
const Bucket &bucket = *(const Bucket *)&btptr[p];
|
||||||
for (int j = 0; j < bucket.size; j++) {
|
for (int j = 0; j < bucket.size; j++) {
|
||||||
if (bucket.elem[j].comp_size == bucket.elem[j].uncomp_size) {
|
if (bucket.elem[j].comp_size == bucket.elem[j].uncomp_size) {
|
||||||
String rstr;
|
String rstr = String::utf8(&sptr[bucket.elem[j].str_offset], bucket.elem[j].uncomp_size);
|
||||||
rstr.append_utf8(&sptr[bucket.elem[j].str_offset], bucket.elem[j].uncomp_size);
|
|
||||||
msgs.push_back(rstr);
|
msgs.push_back(rstr);
|
||||||
} else {
|
} else {
|
||||||
CharString uncomp;
|
CharString uncomp;
|
||||||
uncomp.resize(bucket.elem[j].uncomp_size + 1);
|
uncomp.resize(bucket.elem[j].uncomp_size + 1);
|
||||||
smaz_decompress(&sptr[bucket.elem[j].str_offset], bucket.elem[j].comp_size, uncomp.ptrw(), bucket.elem[j].uncomp_size);
|
smaz_decompress(&sptr[bucket.elem[j].str_offset], bucket.elem[j].comp_size, uncomp.ptrw(), bucket.elem[j].uncomp_size);
|
||||||
String rstr;
|
String rstr = String::utf8(uncomp.get_data());
|
||||||
rstr.append_utf8(uncomp.get_data());
|
|
||||||
msgs.push_back(rstr);
|
msgs.push_back(rstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1127,9 +1127,8 @@ String OS_Unix::get_executable_path() const {
|
|||||||
WARN_PRINT("Couldn't get executable path from sysctl");
|
WARN_PRINT("Couldn't get executable path from sysctl");
|
||||||
return OS::get_executable_path();
|
return OS::get_executable_path();
|
||||||
}
|
}
|
||||||
String b;
|
|
||||||
b.append_utf8(buf);
|
return String::utf8(buf);
|
||||||
return b;
|
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
char temp_path[1];
|
char temp_path[1];
|
||||||
uint32_t buff_size = 1;
|
uint32_t buff_size = 1;
|
||||||
|
|||||||
@@ -66,8 +66,7 @@ Error DAPeer::handle_data() {
|
|||||||
// End of headers
|
// End of headers
|
||||||
if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') {
|
if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') {
|
||||||
r[l - 3] = '\0'; // Null terminate to read string
|
r[l - 3] = '\0'; // Null terminate to read string
|
||||||
String header;
|
String header = String::utf8(r);
|
||||||
header.append_utf8(r);
|
|
||||||
content_length = header.substr(16).to_int();
|
content_length = header.substr(16).to_int();
|
||||||
has_header = true;
|
has_header = true;
|
||||||
req_pos = 0;
|
req_pos = 0;
|
||||||
@@ -93,8 +92,7 @@ Error DAPeer::handle_data() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse data
|
// Parse data
|
||||||
String msg;
|
String msg = String::utf8((const char *)req_buf, req_pos);
|
||||||
msg.append_utf8((const char *)req_buf, req_pos);
|
|
||||||
|
|
||||||
// Apply a timestamp if it there's none yet
|
// Apply a timestamp if it there's none yet
|
||||||
if (!timestamp) {
|
if (!timestamp) {
|
||||||
|
|||||||
@@ -61,9 +61,8 @@ void EngineUpdateLabel::_http_request_completed(int p_result, int p_response_cod
|
|||||||
|
|
||||||
Array version_array;
|
Array version_array;
|
||||||
{
|
{
|
||||||
String s;
|
|
||||||
const uint8_t *r = p_body.ptr();
|
const uint8_t *r = p_body.ptr();
|
||||||
s.append_utf8((const char *)r, p_body.size());
|
String s = String::utf8((const char *)r, p_body.size());
|
||||||
|
|
||||||
Variant result = JSON::parse_string(s);
|
Variant result = JSON::parse_string(s);
|
||||||
if (result == Variant()) {
|
if (result == Variant()) {
|
||||||
|
|||||||
@@ -286,11 +286,7 @@ void ExportTemplateManager::_refresh_mirrors_completed(int p_status, int p_code,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String response_json;
|
String response_json = String::utf8((const char *)p_data.ptr(), p_data.size());
|
||||||
{
|
|
||||||
const uint8_t *r = p_data.ptr();
|
|
||||||
response_json.append_utf8((const char *)r, p_data.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
JSON json;
|
JSON json;
|
||||||
Error err = json.parse(response_json);
|
Error err = json.parse(response_json);
|
||||||
@@ -469,8 +465,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
|
|||||||
ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", file));
|
ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", file));
|
||||||
unzCloseCurrentFile(pkg);
|
unzCloseCurrentFile(pkg);
|
||||||
|
|
||||||
String data_str;
|
String data_str = String::utf8((const char *)uncomp_data.ptr(), uncomp_data.size());
|
||||||
data_str.append_utf8((const char *)uncomp_data.ptr(), uncomp_data.size());
|
|
||||||
data_str = data_str.strip_edges();
|
data_str = data_str.strip_edges();
|
||||||
|
|
||||||
// Version number should be of the form major.minor[.patch].status[.module_config]
|
// Version number should be of the form major.minor[.patch].status[.module_config]
|
||||||
|
|||||||
@@ -1214,14 +1214,7 @@ void EditorAssetLibrary::_api_request(const String &p_request, RequestType p_req
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
|
void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
|
||||||
String str;
|
String str = String::utf8((const char *)p_data.ptr(), (int)p_data.size());
|
||||||
|
|
||||||
{
|
|
||||||
int datalen = p_data.size();
|
|
||||||
const uint8_t *r = p_data.ptr();
|
|
||||||
str.append_utf8((const char *)r, datalen);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool error_abort = true;
|
bool error_abort = true;
|
||||||
|
|
||||||
switch (p_status) {
|
switch (p_status) {
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ Error GDScriptLanguageProtocol::LSPeer::handle_data() {
|
|||||||
// End of headers
|
// End of headers
|
||||||
if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') {
|
if (l > 3 && r[l] == '\n' && r[l - 1] == '\r' && r[l - 2] == '\n' && r[l - 3] == '\r') {
|
||||||
r[l - 3] = '\0'; // Null terminate to read string
|
r[l - 3] = '\0'; // Null terminate to read string
|
||||||
String header;
|
String header = String::utf8(r);
|
||||||
header.append_utf8(r);
|
|
||||||
content_length = header.substr(16).to_int();
|
content_length = header.substr(16).to_int();
|
||||||
has_header = true;
|
has_header = true;
|
||||||
req_pos = 0;
|
req_pos = 0;
|
||||||
@@ -87,8 +86,7 @@ Error GDScriptLanguageProtocol::LSPeer::handle_data() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse data
|
// Parse data
|
||||||
String msg;
|
String msg = String::utf8((const char *)req_buf, req_pos);
|
||||||
msg.append_utf8((const char *)req_buf, req_pos);
|
|
||||||
|
|
||||||
// Reset to read again
|
// Reset to read again
|
||||||
req_pos = 0;
|
req_pos = 0;
|
||||||
|
|||||||
@@ -101,8 +101,7 @@ protected:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String source;
|
String source = String::utf8(reinterpret_cast<const char *>(file.ptr()), file.size());
|
||||||
source.append_utf8(reinterpret_cast<const char *>(file.ptr()), file.size());
|
|
||||||
GDScriptTokenizerBuffer::CompressMode compress_mode = script_mode == EditorExportPreset::MODE_SCRIPT_BINARY_TOKENS_COMPRESSED ? GDScriptTokenizerBuffer::COMPRESS_ZSTD : GDScriptTokenizerBuffer::COMPRESS_NONE;
|
GDScriptTokenizerBuffer::CompressMode compress_mode = script_mode == EditorExportPreset::MODE_SCRIPT_BINARY_TOKENS_COMPRESSED ? GDScriptTokenizerBuffer::COMPRESS_ZSTD : GDScriptTokenizerBuffer::COMPRESS_NONE;
|
||||||
file = GDScriptTokenizerBuffer::parse_code_string(source, compress_mode);
|
file = GDScriptTokenizerBuffer::parse_code_string(source, compress_mode);
|
||||||
if (file.is_empty()) {
|
if (file.is_empty()) {
|
||||||
|
|||||||
@@ -309,8 +309,7 @@ void test(TestType p_type) {
|
|||||||
fa->get_buffer(buf.ptrw(), flen);
|
fa->get_buffer(buf.ptrw(), flen);
|
||||||
buf.write[flen] = 0;
|
buf.write[flen] = 0;
|
||||||
|
|
||||||
String code;
|
String code = String::utf8((const char *)&buf[0]);
|
||||||
code.append_utf8((const char *)&buf[0]);
|
|
||||||
|
|
||||||
Vector<String> lines;
|
Vector<String> lines;
|
||||||
int last = 0;
|
int last = 0;
|
||||||
|
|||||||
@@ -299,8 +299,7 @@ Error GLTFDocument::_parse_json(const String &p_path, Ref<GLTFState> p_state) {
|
|||||||
Vector<uint8_t> array;
|
Vector<uint8_t> array;
|
||||||
array.resize(file->get_length());
|
array.resize(file->get_length());
|
||||||
file->get_buffer(array.ptrw(), array.size());
|
file->get_buffer(array.ptrw(), array.size());
|
||||||
String text;
|
String text = String::utf8((const char *)array.ptr(), array.size());
|
||||||
text.append_utf8((const char *)array.ptr(), array.size());
|
|
||||||
|
|
||||||
JSON json;
|
JSON json;
|
||||||
err = json.parse(text);
|
err = json.parse(text);
|
||||||
@@ -330,8 +329,7 @@ Error GLTFDocument::_parse_glb(Ref<FileAccess> p_file, Ref<GLTFState> p_state) {
|
|||||||
uint32_t len = p_file->get_buffer(json_data.ptrw(), chunk_length);
|
uint32_t len = p_file->get_buffer(json_data.ptrw(), chunk_length);
|
||||||
ERR_FAIL_COND_V(len != chunk_length, ERR_FILE_CORRUPT);
|
ERR_FAIL_COND_V(len != chunk_length, ERR_FILE_CORRUPT);
|
||||||
|
|
||||||
String text;
|
String text = String::utf8((const char *)json_data.ptr(), json_data.size());
|
||||||
text.append_utf8((const char *)json_data.ptr(), json_data.size());
|
|
||||||
|
|
||||||
JSON json;
|
JSON json;
|
||||||
Error err = json.parse(text);
|
Error err = json.parse(text);
|
||||||
|
|||||||
@@ -92,8 +92,7 @@ String cwd() {
|
|||||||
return ".";
|
return ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
String result;
|
String result = String::utf16((buffer.ptr());
|
||||||
result.append_utf16(buffer.ptr());
|
|
||||||
if (result.is_empty()) {
|
if (result.is_empty()) {
|
||||||
return ".";
|
return ".";
|
||||||
}
|
}
|
||||||
@@ -145,8 +144,7 @@ String realpath(const String &p_path) {
|
|||||||
|
|
||||||
::CloseHandle(hFile);
|
::CloseHandle(hFile);
|
||||||
|
|
||||||
String result;
|
String result = String::utf16(buffer.ptr());
|
||||||
result.append_utf16(buffer.ptr());
|
|
||||||
if (result.is_empty()) {
|
if (result.is_empty()) {
|
||||||
return p_path;
|
return p_path;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,8 +100,7 @@ void SceneCacheInterface::process_simplify_path(int p_from, const uint8_t *p_pac
|
|||||||
ERR_FAIL_NULL(root_node);
|
ERR_FAIL_NULL(root_node);
|
||||||
int ofs = 1;
|
int ofs = 1;
|
||||||
|
|
||||||
String methods_md5;
|
String methods_md5 = String::utf8((const char *)(p_packet + ofs), 32);
|
||||||
methods_md5.append_utf8((const char *)(p_packet + ofs), 32);
|
|
||||||
ofs += 33;
|
ofs += 33;
|
||||||
|
|
||||||
int id = decode_uint32(&p_packet[ofs]);
|
int id = decode_uint32(&p_packet[ofs]);
|
||||||
@@ -109,8 +108,7 @@ void SceneCacheInterface::process_simplify_path(int p_from, const uint8_t *p_pac
|
|||||||
|
|
||||||
ERR_FAIL_COND_MSG(peers_info[p_from].recv_nodes.has(id), vformat("Duplicate remote cache ID %d for peer %d", id, p_from));
|
ERR_FAIL_COND_MSG(peers_info[p_from].recv_nodes.has(id), vformat("Duplicate remote cache ID %d for peer %d", id, p_from));
|
||||||
|
|
||||||
String paths;
|
String paths = String::utf8((const char *)(p_packet + ofs), p_packet_len - ofs);
|
||||||
paths.append_utf8((const char *)(p_packet + ofs), p_packet_len - ofs);
|
|
||||||
|
|
||||||
const NodePath path = paths;
|
const NodePath path = paths;
|
||||||
|
|
||||||
|
|||||||
@@ -135,8 +135,7 @@ Node *SceneRPCInterface::_process_get_node(int p_from, const uint8_t *p_packet,
|
|||||||
|
|
||||||
ERR_FAIL_COND_V_MSG(ofs >= p_packet_len, nullptr, "Invalid packet received. Size smaller than declared.");
|
ERR_FAIL_COND_V_MSG(ofs >= p_packet_len, nullptr, "Invalid packet received. Size smaller than declared.");
|
||||||
|
|
||||||
String paths;
|
String paths = String::utf8((const char *)&p_packet[ofs], p_packet_len - ofs);
|
||||||
paths.append_utf8((const char *)&p_packet[ofs], p_packet_len - ofs);
|
|
||||||
|
|
||||||
NodePath np = paths;
|
NodePath np = paths;
|
||||||
|
|
||||||
|
|||||||
@@ -1676,9 +1676,7 @@ String EditorExportPlatformAndroid::_parse_string(const uint8_t *p_bytes, bool p
|
|||||||
str8.write[i] = p_bytes[offset + i];
|
str8.write[i] = p_bytes[offset + i];
|
||||||
}
|
}
|
||||||
str8.write[len] = 0;
|
str8.write[len] = 0;
|
||||||
String str;
|
return String::utf8((const char *)str8.ptr(), len);
|
||||||
str.append_utf8((const char *)str8.ptr(), len);
|
|
||||||
return str;
|
|
||||||
} else {
|
} else {
|
||||||
String str;
|
String str;
|
||||||
for (uint32_t i = 0; i < len; i++) {
|
for (uint32_t i = 0; i < len; i++) {
|
||||||
|
|||||||
@@ -450,9 +450,8 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
|
|||||||
bool valid_rel_specifier = !provisioning_profile_specifier_rel.is_empty();
|
bool valid_rel_specifier = !provisioning_profile_specifier_rel.is_empty();
|
||||||
rel_manual |= valid_rel_specifier;
|
rel_manual |= valid_rel_specifier;
|
||||||
|
|
||||||
String str;
|
String str = String::utf8((const char *)pfile.ptr(), pfile.size());
|
||||||
String strnew;
|
String strnew;
|
||||||
str.append_utf8((const char *)pfile.ptr(), pfile.size());
|
|
||||||
Vector<String> lines = str.split("\n");
|
Vector<String> lines = str.split("\n");
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
if (lines[i].contains("$binary")) {
|
if (lines[i].contains("$binary")) {
|
||||||
|
|||||||
@@ -122,8 +122,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)enterText:(NSString *)substring {
|
- (void)enterText:(NSString *)substring {
|
||||||
String characters;
|
String characters = String::utf8([substring UTF8String]);
|
||||||
characters.append_utf8([substring UTF8String]);
|
|
||||||
|
|
||||||
for (int i = 0; i < characters.size(); i++) {
|
for (int i = 0; i < characters.size(); i++) {
|
||||||
int character = characters[i];
|
int character = characters[i];
|
||||||
|
|||||||
@@ -4140,10 +4140,7 @@ String WaylandThread::keyboard_get_layout_name(int p_index) const {
|
|||||||
SeatState *ss = wl_seat_get_seat_state(wl_seat_current);
|
SeatState *ss = wl_seat_get_seat_state(wl_seat_current);
|
||||||
|
|
||||||
if (ss && ss->xkb_keymap) {
|
if (ss && ss->xkb_keymap) {
|
||||||
String ret;
|
return String::utf8(xkb_keymap_layout_get_name(ss->xkb_keymap, p_index));
|
||||||
ret.append_utf8(xkb_keymap_layout_get_name(ss->xkb_keymap, p_index));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -111,8 +111,7 @@ struct Hints {
|
|||||||
static String get_atom_name(Display *p_disp, Atom p_atom) {
|
static String get_atom_name(Display *p_disp, Atom p_atom) {
|
||||||
char *name = XGetAtomName(p_disp, p_atom);
|
char *name = XGetAtomName(p_disp, p_atom);
|
||||||
ERR_FAIL_NULL_V_MSG(name, String(), "Atom is invalid.");
|
ERR_FAIL_NULL_V_MSG(name, String(), "Atom is invalid.");
|
||||||
String ret;
|
String ret = String::utf8(name);
|
||||||
ret.append_utf8(name);
|
|
||||||
XFree(name);
|
XFree(name);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -3684,8 +3683,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
|
|||||||
keycode -= 'a' - 'A';
|
keycode -= 'a' - 'A';
|
||||||
}
|
}
|
||||||
|
|
||||||
String tmp;
|
String tmp = String::utf8(utf8string, utf8bytes);
|
||||||
tmp.append_utf8(utf8string, utf8bytes);
|
|
||||||
for (int i = 0; i < tmp.length(); i++) {
|
for (int i = 0; i < tmp.length(); i++) {
|
||||||
Ref<InputEventKey> k;
|
Ref<InputEventKey> k;
|
||||||
k.instantiate();
|
k.instantiate();
|
||||||
@@ -3765,8 +3763,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
|
|||||||
char str_xkb[256] = {};
|
char str_xkb[256] = {};
|
||||||
int str_xkb_size = xkb_compose_state_get_utf8(wd.xkb_state, str_xkb, 255);
|
int str_xkb_size = xkb_compose_state_get_utf8(wd.xkb_state, str_xkb, 255);
|
||||||
|
|
||||||
String tmp;
|
String tmp = String::utf8(str_xkb, str_xkb_size);
|
||||||
tmp.append_utf8(str_xkb, str_xkb_size);
|
|
||||||
for (int i = 0; i < tmp.length(); i++) {
|
for (int i = 0; i < tmp.length(); i++) {
|
||||||
Ref<InputEventKey> k;
|
Ref<InputEventKey> k;
|
||||||
k.instantiate();
|
k.instantiate();
|
||||||
|
|||||||
@@ -736,9 +736,8 @@ void EditorExportPlatformMacOS::_make_icon(const Ref<EditorExportPreset> &p_pres
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorExportPlatformMacOS::_fix_privacy_manifest(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist) {
|
void EditorExportPlatformMacOS::_fix_privacy_manifest(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist) {
|
||||||
String str;
|
String str = String::utf8((const char *)plist.ptr(), plist.size());
|
||||||
String strnew;
|
String strnew;
|
||||||
str.append_utf8((const char *)plist.ptr(), plist.size());
|
|
||||||
Vector<String> lines = str.split("\n");
|
Vector<String> lines = str.split("\n");
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
if (lines[i].find("$priv_collection") != -1) {
|
if (lines[i].find("$priv_collection") != -1) {
|
||||||
@@ -815,9 +814,8 @@ void EditorExportPlatformMacOS::_fix_privacy_manifest(const Ref<EditorExportPres
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary) {
|
void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &plist, const String &p_binary) {
|
||||||
String str;
|
String str = String::utf8((const char *)plist.ptr(), plist.size());
|
||||||
String strnew;
|
String strnew;
|
||||||
str.append_utf8((const char *)plist.ptr(), plist.size());
|
|
||||||
Vector<String> lines = str.split("\n");
|
Vector<String> lines = str.split("\n");
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
if (lines[i].contains("$binary")) {
|
if (lines[i].contains("$binary")) {
|
||||||
|
|||||||
@@ -270,8 +270,7 @@
|
|||||||
text.resize([characters length] + 1);
|
text.resize([characters length] + 1);
|
||||||
[characters getCharacters:(unichar *)text.ptrw() range:NSMakeRange(0, [characters length])];
|
[characters getCharacters:(unichar *)text.ptrw() range:NSMakeRange(0, [characters length])];
|
||||||
|
|
||||||
String u32text;
|
String u32text = String::utf16(text.ptr(), text.length());
|
||||||
u32text.append_utf16(text.ptr(), text.length());
|
|
||||||
|
|
||||||
for (int i = 0; i < u32text.length(); i++) {
|
for (int i = 0; i < u32text.length(); i++) {
|
||||||
const char32_t codepoint = u32text[i];
|
const char32_t codepoint = u32text[i];
|
||||||
@@ -652,8 +651,7 @@
|
|||||||
text.resize([characters length] + 1);
|
text.resize([characters length] + 1);
|
||||||
[characters getCharacters:(unichar *)text.ptrw() range:NSMakeRange(0, [characters length])];
|
[characters getCharacters:(unichar *)text.ptrw() range:NSMakeRange(0, [characters length])];
|
||||||
|
|
||||||
String u32text;
|
String u32text = String::utf16(text.ptr(), text.length());
|
||||||
u32text.append_utf16(text.ptr(), text.length());
|
|
||||||
|
|
||||||
DisplayServerMacOS::KeyEvent ke;
|
DisplayServerMacOS::KeyEvent ke;
|
||||||
ke.window_id = window_id;
|
ke.window_id = window_id;
|
||||||
|
|||||||
@@ -110,8 +110,7 @@ Vector<String> OS_MacOS::get_granted_permissions() const {
|
|||||||
BOOL isStale = NO;
|
BOOL isStale = NO;
|
||||||
NSURL *url = [NSURL URLByResolvingBookmarkData:bookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:nil bookmarkDataIsStale:&isStale error:&error];
|
NSURL *url = [NSURL URLByResolvingBookmarkData:bookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:nil bookmarkDataIsStale:&isStale error:&error];
|
||||||
if (!error && !isStale) {
|
if (!error && !isStale) {
|
||||||
String url_string;
|
String url_string = String::utf8([[url path] UTF8String]);
|
||||||
url_string.append_utf8([[url path] UTF8String]);
|
|
||||||
ret.push_back(url_string);
|
ret.push_back(url_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -651,10 +650,7 @@ String OS_MacOS::get_executable_path() const {
|
|||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
return OS::get_executable_path();
|
return OS::get_executable_path();
|
||||||
} else {
|
} else {
|
||||||
String path;
|
return String::utf8(pathbuf);
|
||||||
path.append_utf8(pathbuf);
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -724,8 +720,7 @@ Error OS_MacOS::create_instance(const List<String> &p_arguments, ProcessID *r_ch
|
|||||||
// If executable is bundled, always execute editor instances as an app bundle to ensure app window is registered and activated correctly.
|
// If executable is bundled, always execute editor instances as an app bundle to ensure app window is registered and activated correctly.
|
||||||
NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
|
NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
|
||||||
if (nsappname != nil) {
|
if (nsappname != nil) {
|
||||||
String path;
|
String path = String::utf8([[[NSBundle mainBundle] bundlePath] UTF8String]);
|
||||||
path.append_utf8([[[NSBundle mainBundle] bundlePath] UTF8String]);
|
|
||||||
return create_process(path, p_arguments, r_child_id, false);
|
return create_process(path, p_arguments, r_child_id, false);
|
||||||
} else {
|
} else {
|
||||||
return create_process(get_executable_path(), p_arguments, r_child_id, false);
|
return create_process(get_executable_path(), p_arguments, r_child_id, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user