src/java.base/windows/native/libjava/java_props_md.c

Print this page

        

@@ -143,10 +143,12 @@
         return NULL;
     }
     cp = GetConsoleCP();
     if (cp >= 874 && cp <= 950)
         sprintf(buf, "ms%d", cp);
+    else if (cp == 65001)
+        sprintf(buf, "UTF-8");
     else
         sprintf(buf, "cp%d", cp);
     return buf;
 }
 

@@ -686,21 +688,31 @@
                 sprops.encoding = "MS950_HKSCS";
                 sprops.sun_jnu_encoding = "MS950_HKSCS";
             }
 
             hStdOutErr = GetStdHandle(STD_OUTPUT_HANDLE);
-            if (hStdOutErr != INVALID_HANDLE_VALUE &&
-                GetFileType(hStdOutErr) == FILE_TYPE_CHAR) {
+            if (hStdOutErr != INVALID_HANDLE_VALUE) {
+                switch(GetFileType(hStdOutErr)) {
+                    case FILE_TYPE_DISK:
+                    case FILE_TYPE_CHAR:
+                    case FILE_TYPE_PIPE:
                 sprops.sun_stdout_encoding = getConsoleEncoding();
+                        break;
+                }
             }
             hStdOutErr = GetStdHandle(STD_ERROR_HANDLE);
-            if (hStdOutErr != INVALID_HANDLE_VALUE &&
-                GetFileType(hStdOutErr) == FILE_TYPE_CHAR) {
+            if (hStdOutErr != INVALID_HANDLE_VALUE) {
+                switch (GetFileType(hStdOutErr)) {
+                    case FILE_TYPE_DISK:
+                    case FILE_TYPE_CHAR:
+                    case FILE_TYPE_PIPE:
                 if (sprops.sun_stdout_encoding != NULL)
                     sprops.sun_stderr_encoding = sprops.sun_stdout_encoding;
                 else
                     sprops.sun_stderr_encoding = getConsoleEncoding();
+                        break;
+                }
             }
         }
     }
 
     sprops.unicode_encoding = "UnicodeLittle";