From ba073713288a2f3a32437a0a7a0fd857ce2d9f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Thu, 5 Dec 2013 11:20:29 +0000 Subject: [PATCH] support broken LC_CTYPE in OSX --- os/pl-ctype.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/os/pl-ctype.c b/os/pl-ctype.c index 2666a8d50..6b22acc8a 100644 --- a/os/pl-ctype.c +++ b/os/pl-ctype.c @@ -846,16 +846,26 @@ initEncoding(void) if ( LD ) { if ( !LD->encoding ) - { char *enc; + { char *enc, *encp; if ( !init_locale() ) { LD->encoding = ENC_ISO_LATIN_1; } else if ( (enc = setlocale(LC_CTYPE, NULL)) ) { LD->encoding = ENC_ANSI; /* text encoding */ - if ( (enc = strchr(enc, '.')) ) + if ( (encp = strchr(enc, '.')) ) { const enc_map *m; - enc++; /* skip '.' */ + encp++; /* skip '.' */ + + for ( m=map; m->name; m++ ) + { if ( strcmp(encp, m->name) == 0 ) + { LD->encoding = m->encoding; + break; + } + } + } else { + /* vsc: just test LC_CTYPE, works on Macs */ + const enc_map *m; for ( m=map; m->name; m++ ) { if ( strcmp(enc, m->name) == 0 )