Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix encoding problem, use utf8 encoding #3

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions internal/nsalert/alert.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#import <AppKit/NSAlert.h>

void alert(char *title, char *message, NSAlertStyle style) {
NSString* titleString = [NSString stringWithCString:title encoding:[NSString defaultCStringEncoding]];
NSString* messageString = [NSString stringWithCString:message encoding:[NSString defaultCStringEncoding]];
NSString* titleString = [NSString stringWithCString:title encoding:NSUTF8StringEncoding];
NSString* messageString = [NSString stringWithCString:message encoding:NSUTF8StringEncoding];
if([NSThread isMainThread]) {
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = titleString;
Expand Down Expand Up @@ -40,10 +40,10 @@ void error(char *title, char *message) {
}

bool question(char *title, char *message, char *defaultButton, char*alternateButton) {
NSString* titleString = [NSString stringWithCString:title encoding:[NSString defaultCStringEncoding]];
NSString* messageString = [NSString stringWithCString:message encoding:[NSString defaultCStringEncoding]];
NSString* defaultButtonString = [NSString stringWithCString:defaultButton encoding:[NSString defaultCStringEncoding]];
NSString* alternateButtonString = [NSString stringWithCString:alternateButton encoding:[NSString defaultCStringEncoding]];
NSString* titleString = [NSString stringWithCString:title encoding:NSUTF8StringEncoding];
NSString* messageString = [NSString stringWithCString:message encoding:NSUTF8StringEncoding];
NSString* defaultButtonString = [NSString stringWithCString:defaultButton encoding:NSUTF8StringEncoding];
NSString* alternateButtonString = [NSString stringWithCString:alternateButton encoding:NSUTF8StringEncoding];

__block NSInteger button;
if([NSThread isMainThread]) {
Expand Down
2 changes: 1 addition & 1 deletion internal/nsalert/alert_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"unsafe"
)

// Message displays a basic alert with an "OK" button
// Info displays a basic alert with an "OK" button
func Info(title, message string) error {
cTitle := C.CString(title)
defer C.free(unsafe.Pointer(cTitle))
Expand Down