Merge pull request #104810 from kiroxas/utf8_cleanup

Replace `append_utfx` with direct `String::utfx`
This commit is contained in:
Thaddeus Crews
2025-03-31 12:03:44 -05:00
30 changed files with 49 additions and 123 deletions

View File

@ -1676,9 +1676,7 @@ String EditorExportPlatformAndroid::_parse_string(const uint8_t *p_bytes, bool p
str8.write[i] = p_bytes[offset + i];
}
str8.write[len] = 0;
String str;
str.append_utf8((const char *)str8.ptr(), len);
return str;
return String::utf8((const char *)str8.ptr(), len);
} else {
String str;
for (uint32_t i = 0; i < len; i++) {

View File

@ -450,9 +450,8 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
bool valid_rel_specifier = !provisioning_profile_specifier_rel.is_empty();
rel_manual |= valid_rel_specifier;
String str;
String str = String::utf8((const char *)pfile.ptr(), pfile.size());
String strnew;
str.append_utf8((const char *)pfile.ptr(), pfile.size());
Vector<String> lines = str.split("\n");
for (int i = 0; i < lines.size(); i++) {
if (lines[i].contains("$binary")) {

View File

@ -122,8 +122,7 @@
}
- (void)enterText:(NSString *)substring {
String characters;
characters.append_utf8([substring UTF8String]);
String characters = String::utf8([substring UTF8String]);
for (int i = 0; i < characters.size(); i++) {
int character = characters[i];

View File

@ -4140,10 +4140,7 @@ String WaylandThread::keyboard_get_layout_name(int p_index) const {
SeatState *ss = wl_seat_get_seat_state(wl_seat_current);
if (ss && ss->xkb_keymap) {
String ret;
ret.append_utf8(xkb_keymap_layout_get_name(ss->xkb_keymap, p_index));
return ret;
return String::utf8(xkb_keymap_layout_get_name(ss->xkb_keymap, p_index));
}
return "";

View File

@ -111,8 +111,7 @@ struct Hints {
static String get_atom_name(Display *p_disp, Atom p_atom) {
char *name = XGetAtomName(p_disp, p_atom);
ERR_FAIL_NULL_V_MSG(name, String(), "Atom is invalid.");
String ret;
ret.append_utf8(name);
String ret = String::utf8(name);
XFree(name);
return ret;
}
@ -3684,8 +3683,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
keycode -= 'a' - 'A';
}
String tmp;
tmp.append_utf8(utf8string, utf8bytes);
String tmp = String::utf8(utf8string, utf8bytes);
for (int i = 0; i < tmp.length(); i++) {
Ref<InputEventKey> k;
k.instantiate();
@ -3765,8 +3763,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event,
char str_xkb[256] = {};
int str_xkb_size = xkb_compose_state_get_utf8(wd.xkb_state, str_xkb, 255);
String tmp;
tmp.append_utf8(str_xkb, str_xkb_size);
String tmp = String::utf8(str_xkb, str_xkb_size);
for (int i = 0; i < tmp.length(); i++) {
Ref<InputEventKey> k;
k.instantiate();

View File

@ -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) {
String str;
String str = String::utf8((const char *)plist.ptr(), plist.size());
String strnew;
str.append_utf8((const char *)plist.ptr(), plist.size());
Vector<String> lines = str.split("\n");
for (int i = 0; i < lines.size(); i++) {
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) {
String str;
String str = String::utf8((const char *)plist.ptr(), plist.size());
String strnew;
str.append_utf8((const char *)plist.ptr(), plist.size());
Vector<String> lines = str.split("\n");
for (int i = 0; i < lines.size(); i++) {
if (lines[i].contains("$binary")) {

View File

@ -270,8 +270,7 @@
text.resize([characters length] + 1);
[characters getCharacters:(unichar *)text.ptrw() range:NSMakeRange(0, [characters length])];
String u32text;
u32text.append_utf16(text.ptr(), text.length());
String u32text = String::utf16(text.ptr(), text.length());
for (int i = 0; i < u32text.length(); i++) {
const char32_t codepoint = u32text[i];
@ -652,8 +651,7 @@
text.resize([characters length] + 1);
[characters getCharacters:(unichar *)text.ptrw() range:NSMakeRange(0, [characters length])];
String u32text;
u32text.append_utf16(text.ptr(), text.length());
String u32text = String::utf16(text.ptr(), text.length());
DisplayServerMacOS::KeyEvent ke;
ke.window_id = window_id;

View File

@ -110,8 +110,7 @@ Vector<String> OS_MacOS::get_granted_permissions() const {
BOOL isStale = NO;
NSURL *url = [NSURL URLByResolvingBookmarkData:bookmark options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:nil bookmarkDataIsStale:&isStale error:&error];
if (!error && !isStale) {
String url_string;
url_string.append_utf8([[url path] UTF8String]);
String url_string = String::utf8([[url path] UTF8String]);
ret.push_back(url_string);
}
}
@ -651,10 +650,7 @@ String OS_MacOS::get_executable_path() const {
if (ret <= 0) {
return OS::get_executable_path();
} else {
String path;
path.append_utf8(pathbuf);
return path;
return String::utf8(pathbuf);
}
}
@ -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.
NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
if (nsappname != nil) {
String path;
path.append_utf8([[[NSBundle mainBundle] bundlePath] UTF8String]);
String path = String::utf8([[[NSBundle mainBundle] bundlePath] UTF8String]);
return create_process(path, p_arguments, r_child_id, false);
} else {
return create_process(get_executable_path(), p_arguments, r_child_id, false);