changeset 12442:c26b27c60fdd

localcharset: Fix comment.
author Bruno Haible <bruno@clisp.org>
date Sun, 13 Dec 2009 12:07:21 +0100
parents ab69336c0252
children 3a97f22a64eb
files ChangeLog lib/localcharset.c
diffstat 2 files changed, 23 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-12-13  Bruno Haible  <bruno@clisp.org>
+
+	* lib/localcharset.c (locale_charset): Fix comment about use of GetACP.
+
 2009-12-13  Jim Meyering  <meyering@redhat.com>
 
 	maint.mk (null_AM_MAKEFLAGS, built_programs): remove unused definitions
--- a/lib/localcharset.c
+++ b/lib/localcharset.c
@@ -369,7 +369,7 @@
   codeset = nl_langinfo (CODESET);
 
 #  ifdef __CYGWIN__
-  /* Cygwin 2006 does not have locales.  nl_langinfo (CODESET) always
+  /* Cygwin 1.5.x does not have locales.  nl_langinfo (CODESET) always
      returns "US-ASCII".  As long as this is not fixed, return the suffix
      of the locale name from the environment variables (if present) or
      the codepage as a number.  */
@@ -409,7 +409,17 @@
             }
         }
 
-      /* Woe32 has a function returning the locale's codepage as a number.  */
+      /* Woe32 has a function returning the locale's codepage as a number:
+         GetACP().  This encoding is used by Cygwin, unless the user has set
+         the environment variable CYGWIN=codepage:oem (which very few people
+         do).
+         Output directed to console windows needs to be converted (to
+         GetOEMCP() if the console is using a raster font, or to
+         GetConsoleOutputCP() if it is using a TrueType font).  Cygwin does
+         this conversion transparently (see winsup/cygwin/fhandler_console.cc),
+         converting to GetConsoleOutputCP().  This leads to correct results,
+         except when SetConsoleOutputCP has been called and a raster font is
+         in use.  */
       sprintf (buf, "CP%u", GetACP ());
       codeset = buf;
     }
@@ -449,19 +459,13 @@
 
   static char buf[2 + 10 + 1];
 
-  /* Woe32 has a function returning the locale's codepage as a number.
-     When the output goes to a console window, in Windows 95, it would have
-     been appropriate to use GetOEMCP() instead of GetACP().  But this has
-     been corrected: In Windows XP SP3, consoles accept output in the
-     GetACP() encoding.  The GetConsoleOutputCP() function still returns
-     the same as GetOEMCP() (not GetACP()!), but the font handling in the
-     console actually uses the GetACP() encoding.  If you want to "correct"
-     this by calling SetConsoleOutputCP(GetACP()), then for a TrueType font
-     it has no visible effect on the displayed glyphs, whereas when a raster
-     font is in use, the console performs an extra conversion from GetOEMCP()
-     to GetACP() encoding, thus changing the effective codepage of the
-     console from GetACP() to GetOEMCP()!  In summary, GetConsoleOutputCP()
-     and SetConsoleOutputCP() are now completely broken.  */
+  /* Woe32 has a function returning the locale's codepage as a number:
+     GetACP().
+     When the output goes to a console window, it needs to be provided in
+     GetOEMCP() encoding if the console is using a raster font, or in
+     GetConsoleOutputCP() encoding if it is using a TrueType font.
+     But in GUI programs and for output sent to files and pipes, GetACP()
+     encoding is the best bet.  */
   sprintf (buf, "CP%u", GetACP ());
   codeset = buf;