Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29a8663

Browse files
authored
Merge pull request matplotlib#23558 from greglucas/macosx-utf8-strings
MNT: Use UTF-8 string in macosx backend
2 parents 80d79eb + 57239da commit 29a8663

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/_macosx.m

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -716,10 +716,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
716716
if (!PyArg_ParseTuple(args, "s", &title)) {
717717
return NULL;
718718
}
719-
NSString* ns_title = [[NSString alloc]
720-
initWithCString: title
721-
encoding: NSUTF8StringEncoding];
722-
[self->window setTitle: ns_title];
719+
[self->window setTitle: [NSString stringWithUTF8String: title]];
723720
Py_RETURN_NONE;
724721
}
725722

@@ -946,10 +943,8 @@ -(void)save_figure:(id)sender { gil_call_method(toolbar, "save_figure"); }
946943
rect.origin.y = 0.5*(height - rect.size.height);
947944

948945
for (int i = 0; i < 7; i++) {
949-
NSString* filename = [NSString stringWithCString: images[i]
950-
encoding: NSUTF8StringEncoding];
951-
NSString* tooltip = [NSString stringWithCString: tooltips[i]
952-
encoding: NSUTF8StringEncoding];
946+
NSString* filename = [NSString stringWithUTF8String: images[i]];
947+
NSString* tooltip = [NSString stringWithUTF8String: tooltips[i]];
953948
NSImage* image = [[NSImage alloc] initWithContentsOfFile: filename];
954949
buttons[i] = [[NSButton alloc] initWithFrame: rect];
955950
[image setSize: size];

0 commit comments

Comments
 (0)