Add transition period hack allowing old locale names return proper codeset too
This commit is contained in:
parent
085d234587
commit
4e86aa7f9d
@ -36,6 +36,8 @@
|
||||
#include "lmonetary.h"
|
||||
#include "lmessages.h"
|
||||
|
||||
#define TRANSITION_PERIOD_HACK
|
||||
|
||||
#define _REL(BASE) ((int)item-BASE)
|
||||
|
||||
char *
|
||||
@ -43,16 +45,41 @@ nl_langinfo(nl_item item) {
|
||||
|
||||
char *ret, *s, *cs;
|
||||
static char *csym = NULL;
|
||||
#ifdef TRANSITION_PERIOD_HACK
|
||||
static char *cset = NULL;
|
||||
#endif /* TRANSITION_PERIOD_HACK */
|
||||
|
||||
switch (item) {
|
||||
case CODESET:
|
||||
ret = "";
|
||||
if ((s = setlocale(LC_CTYPE, NULL)) != NULL) {
|
||||
if ((cs = strchr(s, '.')) != NULL)
|
||||
if ((cs = strchr(s, '.')) != NULL) {
|
||||
ret = cs + 1;
|
||||
else if (strcmp(s, "C") == 0 ||
|
||||
strcmp(s, "POSIX") == 0 ||
|
||||
strstr(s, "ASCII") != NULL)
|
||||
#ifdef TRANSITION_PERIOD_HACK
|
||||
if (strncmp(ret, "ISO_", 4) == 0) {
|
||||
int slen = strlen(ret);
|
||||
|
||||
if ((cset = reallocf(cset, slen)) != NULL) {
|
||||
strcpy(cset, "ISO");
|
||||
strcat(cset, ret + 4);
|
||||
ret = cset;
|
||||
}
|
||||
} else if (strcmp(ret, "EUC") == 0) {
|
||||
if (strncmp(s, "ja_JP", 5) == 0)
|
||||
ret = "eucJP";
|
||||
else if (strncmp(s, "ko_KR", 5) == 0)
|
||||
ret = "eucKR";
|
||||
else if (strncmp(s, "zh_CN", 5) == 0)
|
||||
ret = "eucCN";
|
||||
} else if (strcmp(ret, "ASCII") == 0)
|
||||
ret = "US-ASCII";
|
||||
#endif /* TRANSITION_PERIOD_HACK */
|
||||
} else if (strcmp(s, "C") == 0 ||
|
||||
strcmp(s, "POSIX") == 0
|
||||
#ifdef TRANSITION_PERIOD_HACK
|
||||
|| strstr(s, "ASCII") != NULL
|
||||
#endif /* TRANSITION_PERIOD_HACK */
|
||||
)
|
||||
ret = "US-ASCII";
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user