Skip to content

Commit

Permalink
fix encoding of utf8 languages on macOS (use utf8 encoding) (#3)
Browse files Browse the repository at this point in the history
Co-authored-by: Frank Chiarulli Jr <frank@frankchiarulli.com>
  • Loading branch information
LinkinStars and fcjr authored Aug 17, 2023
1 parent 6af9ff7 commit eac29aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit eac29aa

Please sign in to comment.