fix Chinese title on mac

This commit is contained in:
jfliu 2023-01-13 17:20:28 +08:00 committed by akallabeth
parent a691b48bc0
commit 5b44bc63e8

View File

@ -67,8 +67,9 @@ void mac_set_view_size(rdpContext *context, MRDPView *view);
if (settings->WindowTitle && settings->WindowTitle[0]) if (settings->WindowTitle && settings->WindowTitle[0])
{ {
winTitle = [[NSString alloc] initWithCString:settings->WindowTitle winTitle = [[NSString alloc]
encoding:NSUTF8StringEncoding]; initWithFormat:@"%@", [NSString stringWithCString:settings->WindowTitle
encoding:NSUTF8StringEncoding]];
} }
else else
{ {
@ -76,7 +77,7 @@ void mac_set_view_size(rdpContext *context, MRDPView *view);
initWithFormat:@"%@:%u", initWithFormat:@"%@:%u",
[NSString stringWithCString:settings->ServerHostname [NSString stringWithCString:settings->ServerHostname
encoding:NSUTF8StringEncoding], encoding:NSUTF8StringEncoding],
settings -> ServerPort]; settings->ServerPort];
} }
[window setTitle:winTitle]; [window setTitle:winTitle];
@ -132,7 +133,7 @@ void mac_set_view_size(rdpContext *context, MRDPView *view);
if ([str isEqualToString:@"-NSDocumentRevisionsDebugMode"]) if ([str isEqualToString:@"-NSDocumentRevisionsDebugMode"])
continue; continue;
length = (int)([str length] + 1); length = (int)([str lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1);
cptr = (char *)malloc(length); cptr = (char *)malloc(length);
sprintf_s(cptr, length, "%s", [str UTF8String]); sprintf_s(cptr, length, "%s", [str UTF8String]);
context->argv[i++] = cptr; context->argv[i++] = cptr;