Mercurial > dwindows
comparison mac/dw.m @ 1786:9a32d4216f24
Make sure we set the locale on Mac and it is UTF-8.
Otherwise the UTF-8/Wide conversions won't work.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 25 Jul 2012 02:15:35 +0000 |
parents | 86ace55df07b |
children | 9d499b162fe1 |
comparison
equal
deleted
inserted
replaced
1785:c5ea64e8b436 | 1786:9a32d4216f24 |
---|---|
10545 * newthread: True if this is the only thread. | 10545 * newthread: True if this is the only thread. |
10546 * False if there is already a message loop running. | 10546 * False if there is already a message loop running. |
10547 */ | 10547 */ |
10548 int API dw_init(int newthread, int argc, char *argv[]) | 10548 int API dw_init(int newthread, int argc, char *argv[]) |
10549 { | 10549 { |
10550 char *lang = getenv("LANG"); | |
10551 | |
10550 /* Correct the startup path if run from a bundle */ | 10552 /* Correct the startup path if run from a bundle */ |
10551 if(argc > 0 && argv[0]) | 10553 if(argc > 0 && argv[0]) |
10552 { | 10554 { |
10553 char *pathcopy = strdup(argv[0]); | 10555 char *pathcopy = strdup(argv[0]); |
10554 char *app = strstr(pathcopy, ".app/"); | 10556 char *app = strstr(pathcopy, ".app/"); |
10586 | 10588 |
10587 /* Get the operating system version */ | 10589 /* Get the operating system version */ |
10588 NSString *version = [[NSProcessInfo processInfo] operatingSystemVersionString]; | 10590 NSString *version = [[NSProcessInfo processInfo] operatingSystemVersionString]; |
10589 const char *versionstr = [version UTF8String]; | 10591 const char *versionstr = [version UTF8String]; |
10590 sscanf(versionstr, "Version %d.%d.%d", &DWOSMajor, &DWOSMinor, &DWOSBuild); | 10592 sscanf(versionstr, "Version %d.%d.%d", &DWOSMajor, &DWOSMinor, &DWOSBuild); |
10593 /* Set the locale... if it is UTF-8 pass it | |
10594 * directly, otherwise specify UTF-8 explicitly. | |
10595 */ | |
10596 setlocale(LC_ALL, lang && strstr(lang, ".UTF-8") ? lang : "UTF-8"); | |
10591 /* Create the application object */ | 10597 /* Create the application object */ |
10592 DWApp = [NSApplication sharedApplication]; | 10598 DWApp = [NSApplication sharedApplication]; |
10593 /* Create object for handling timers */ | 10599 /* Create object for handling timers */ |
10594 DWHandler = [[DWTimerHandler alloc] init]; | 10600 DWHandler = [[DWTimerHandler alloc] init]; |
10595 /* If we aren't using garbage collection we need autorelease pools */ | 10601 /* If we aren't using garbage collection we need autorelease pools */ |