summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-01-06 11:34:10 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-01-06 14:35:22 +0200
commitc69e0d16bc8adbe3d984f4f9953412986ed02791 (patch)
treec164078533bebe91a544618bf61c0a1045de886a
parent1f0dc026491539ed07f144e0aad29cdfeaa5f66d (diff)
Fix multiple missing UTF-8 decoding.
-rw-r--r--core/io/file_access_zip.cpp2
-rw-r--r--core/io/resource.cpp4
-rw-r--r--core/os/os.cpp2
-rw-r--r--doc/classes/StreamPeer.xml2
-rw-r--r--drivers/alsa/audio_driver_alsa.cpp4
-rw-r--r--drivers/coreaudio/audio_driver_coreaudio.cpp4
-rw-r--r--modules/camera/camera_osx.mm2
-rw-r--r--modules/gdscript/tests/gdscript_test_runner.cpp8
-rw-r--r--platform/iphone/ios.mm2
-rw-r--r--platform/iphone/joypad_iphone.mm2
-rw-r--r--platform/javascript/display_server_javascript.cpp4
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp4
-rw-r--r--platform/osx/os_osx.mm4
13 files changed, 22 insertions, 22 deletions
diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp
index d90a0c9110..6347862775 100644
--- a/core/io/file_access_zip.cpp
+++ b/core/io/file_access_zip.cpp
@@ -189,7 +189,7 @@ bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files, uint6
f.package = pkg_num;
unzGetFilePos(zfile, &f.file_pos);
- String fname = String("res://") + filename_inzip;
+ String fname = String("res://") + String::utf8(filename_inzip);
files[fname] = f;
uint8_t md5[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
diff --git a/core/io/resource.cpp b/core/io/resource.cpp
index 311d71638b..66d5c54b53 100644
--- a/core/io/resource.cpp
+++ b/core/io/resource.cpp
@@ -520,8 +520,8 @@ void ResourceCache::dump(const char *p_file, bool p_short) {
FileAccess *f = nullptr;
if (p_file) {
- f = FileAccess::open(p_file, FileAccess::WRITE);
- ERR_FAIL_COND_MSG(!f, "Cannot create file at path '" + String(p_file) + "'.");
+ f = FileAccess::open(String::utf8(p_file), FileAccess::WRITE);
+ ERR_FAIL_COND_MSG(!f, "Cannot create file at path '" + String::utf8(p_file) + "'.");
}
const String *K = nullptr;
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 506e968bf6..0032e8e4bc 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -346,7 +346,7 @@ String OS::get_model_name() const {
}
void OS::set_cmdline(const char *p_execpath, const List<String> &p_args) {
- _execpath = p_execpath;
+ _execpath = String::utf8(p_execpath);
_cmdline = p_args;
}
diff --git a/doc/classes/StreamPeer.xml b/doc/classes/StreamPeer.xml
index 805f056289..69d224ed24 100644
--- a/doc/classes/StreamPeer.xml
+++ b/doc/classes/StreamPeer.xml
@@ -70,7 +70,7 @@
<return type="String" />
<argument index="0" name="bytes" type="int" default="-1" />
<description>
- Gets a string with byte-length [code]bytes[/code] from the stream. If [code]bytes[/code] is negative (default) the length will be read from the stream using the reverse process of [method put_string].
+ Gets an ASCII string with byte-length [code]bytes[/code] from the stream. If [code]bytes[/code] is negative (default) the length will be read from the stream using the reverse process of [method put_string].
</description>
</method>
<method name="get_u16">
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp
index 9cf2b7a7eb..7884269103 100644
--- a/drivers/alsa/audio_driver_alsa.cpp
+++ b/drivers/alsa/audio_driver_alsa.cpp
@@ -283,9 +283,9 @@ Array AudioDriverALSA::get_device_list() {
if (name != nullptr && !strncmp(name, "plughw", 6)) {
if (desc) {
- list.push_back(String(name) + ";" + String(desc));
+ list.push_back(String::utf8(name) + ";" + String::utf8(desc));
} else {
- list.push_back(String(name));
+ list.push_back(String::utf8(name));
}
}
diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp
index 7364dbe2e7..e37a53fede 100644
--- a/drivers/coreaudio/audio_driver_coreaudio.cpp
+++ b/drivers/coreaudio/audio_driver_coreaudio.cpp
@@ -540,7 +540,7 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) {
ERR_FAIL_NULL_V_MSG(buffer, list, "Out of memory.");
if (CFStringGetCString(cfname, buffer, maxSize, kCFStringEncodingUTF8)) {
// Append the ID to the name in case we have devices with duplicate name
- list.push_back(String(buffer) + " (" + itos(audioDevices[i]) + ")");
+ list.push_back(String::utf8(buffer) + " (" + itos(audioDevices[i]) + ")");
}
memfree(buffer);
@@ -597,7 +597,7 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
char *buffer = (char *)memalloc(maxSize);
ERR_FAIL_NULL_MSG(buffer, "Out of memory.");
if (CFStringGetCString(cfname, buffer, maxSize, kCFStringEncodingUTF8)) {
- String name = String(buffer) + " (" + itos(audioDevices[i]) + ")";
+ String name = String::utf8(buffer) + " (" + itos(audioDevices[i]) + ")";
if (name == device) {
deviceId = audioDevices[i];
found = true;
diff --git a/modules/camera/camera_osx.mm b/modules/camera/camera_osx.mm
index 626cc3f285..391006bfc2 100644
--- a/modules/camera/camera_osx.mm
+++ b/modules/camera/camera_osx.mm
@@ -231,7 +231,7 @@ void CameraFeedOSX::set_device(AVCaptureDevice *p_device) {
// get some info
NSString *device_name = p_device.localizedName;
- name = device_name.UTF8String;
+ name = String::utf8(device_name.UTF8String);
position = CameraFeed::FEED_UNSPECIFIED;
if ([p_device position] == AVCaptureDevicePositionBack) {
position = CameraFeed::FEED_BACK;
diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp
index 5845f84605..47772b8039 100644
--- a/modules/gdscript/tests/gdscript_test_runner.cpp
+++ b/modules/gdscript/tests/gdscript_test_runner.cpp
@@ -362,16 +362,16 @@ void GDScriptTest::error_handler(void *p_this, const char *p_function, const cha
}
builder.append("\n>> on function: ");
- builder.append(p_function);
+ builder.append(String::utf8(p_function));
builder.append("()\n>> ");
- builder.append(String(p_file).trim_prefix(self->base_dir));
+ builder.append(String::utf8(p_file).trim_prefix(self->base_dir));
builder.append("\n>> ");
builder.append(itos(p_line));
builder.append("\n>> ");
- builder.append(p_error);
+ builder.append(String::utf8(p_error));
if (strlen(p_explanation) > 0) {
builder.append("\n>> ");
- builder.append(p_explanation);
+ builder.append(String::utf8(p_explanation));
}
builder.append("\n");
diff --git a/platform/iphone/ios.mm b/platform/iphone/ios.mm
index 91a2e6c228..da21ad0ace 100644
--- a/platform/iphone/ios.mm
+++ b/platform/iphone/ios.mm
@@ -65,7 +65,7 @@ String iOS::get_model() const {
NSString *platform = [NSString stringWithCString:model encoding:NSUTF8StringEncoding];
free(model);
const char *str = [platform UTF8String];
- return String(str != nullptr ? str : "");
+ return String::utf8(str != nullptr ? str : "");
}
String iOS::get_rate_url(int p_app_id) const {
diff --git a/platform/iphone/joypad_iphone.mm b/platform/iphone/joypad_iphone.mm
index 8c6e546515..2630b42da0 100644
--- a/platform/iphone/joypad_iphone.mm
+++ b/platform/iphone/joypad_iphone.mm
@@ -159,7 +159,7 @@ void JoypadIPhone::start_processing() {
};
// tell Godot about our new controller
- Input::get_singleton()->joy_connection_changed(joy_id, true, [controller.vendorName UTF8String]);
+ Input::get_singleton()->joy_connection_changed(joy_id, true, String::utf8([controller.vendorName UTF8String]));
// add it to our dictionary, this will retain our controllers
[self.connectedJoypads setObject:controller forKey:[NSNumber numberWithInt:joy_id]];
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp
index f0b06d841e..5d960ef80c 100644
--- a/platform/javascript/display_server_javascript.cpp
+++ b/platform/javascript/display_server_javascript.cpp
@@ -500,7 +500,7 @@ void DisplayServerJavaScript::vk_input_text_callback(const char *p_text, int p_c
return;
}
// Call input_text
- Variant event = String(p_text);
+ Variant event = String::utf8(p_text);
Variant *eventp = &event;
Variant ret;
Callable::CallError ce;
@@ -590,7 +590,7 @@ Vector<String> DisplayServerJavaScript::get_rendering_drivers_func() {
// Clipboard
void DisplayServerJavaScript::update_clipboard_callback(const char *p_text) {
- get_singleton()->clipboard = p_text;
+ get_singleton()->clipboard = String::utf8(p_text);
}
void DisplayServerJavaScript::clipboard_set(const String &p_text) {
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
index fe891e1c6a..b5f127bb16 100644
--- a/platform/linuxbsd/os_linuxbsd.cpp
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -431,7 +431,7 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
if (trash_path.is_empty()) {
char *dhome = getenv("XDG_DATA_HOME");
if (dhome) {
- trash_path = String(dhome) + "/Trash";
+ trash_path = String::utf8(dhome) + "/Trash";
}
}
@@ -439,7 +439,7 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
if (trash_path.is_empty()) {
char *home = getenv("HOME");
if (home) {
- trash_path = String(home) + "/.local/share/Trash";
+ trash_path = String::utf8(home) + "/.local/share/Trash";
}
}
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index e57b503ddc..7d07b0076b 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -586,7 +586,7 @@ void OS_OSX::run() {
quit = true;
}
} @catch (NSException *exception) {
- ERR_PRINT("NSException: " + String([exception reason].UTF8String));
+ ERR_PRINT("NSException: " + String::utf8([exception reason].UTF8String));
}
};
@@ -602,7 +602,7 @@ Error OS_OSX::move_to_trash(const String &p_path) {
NSError *err;
if (![fm trashItemAtURL:url resultingItemURL:nil error:&err]) {
- ERR_PRINT("trashItemAtURL error: " + String(err.localizedDescription.UTF8String));
+ ERR_PRINT("trashItemAtURL error: " + String::utf8(err.localizedDescription.UTF8String));
return FAILED;
}