From 88116ad22eab8c3b4987949e5f94040834ad1833 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sun, 24 Jan 2010 12:18:20 +0000 Subject: [PATCH] * libc/locale/nl_langinfo.c (nl_langinfo): Return "CP932" when using SJIS on Cygwin. Explain why. --- newlib/ChangeLog | 5 +++++ newlib/libc/locale/nl_langinfo.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 187978c58..5b21f2b1b 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +2010-01-24 Corinna Vinschen + + * libc/locale/nl_langinfo.c (nl_langinfo): Return "CP932" when using + SJIS on Cygwin. Explain why. + 2010-01-23 Corinna Vinschen * libc/locale/locale.c (loadlocale): Allow CP932 as alias for SJIS. diff --git a/newlib/libc/locale/nl_langinfo.c b/newlib/libc/locale/nl_langinfo.c index ae7228cf6..cd86c158d 100644 --- a/newlib/libc/locale/nl_langinfo.c +++ b/newlib/libc/locale/nl_langinfo.c @@ -79,6 +79,20 @@ _DEFUN(nl_langinfo, (item), else if (strcmp (ret + 2, "21866") == 0) ret = "KOI8-U"; } + else if (ret[0] == 'S'/*JIS*/) + { + /* Cygwin uses MSFT's implementation of SJIS, which differs + in some codepoints from the real thing, especially + 0x5c: yen sign instead of backslash, + 0x7e: overline instead of tilde. + We can't use the real SJIS since otherwise Win32 + pathnames would become invalid. OTOH, if we return + "SJIS" here, then libiconv will do mb<->wc conversion + differently to our internal functions. Therefore we + return what we really implement, CP932. This is handled + fine by libiconv. */ + ret = "CP932"; + } #else ret = ""; if ((s = setlocale(LC_CTYPE, NULL)) != NULL) {