Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8264813

The message sent by the system is parsed with wrong encoding in some languages.

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10.0.19042.867

      openjdk version "1.8.0_282"
      OpenJDK Runtime Environment (build 1.8.0_282-b08)
      OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      The issue can be reproduced in CJK languages, not sure if there are more languages that can make the same error.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Take Simplified Chinese as an example:
      1. Install Windows Simplified Chinese Edition;
      2. In 「控制面板 -- 时钟和区域 -- 区域 -- 管理 -- 更改系统区域设置」, check the box 「Beta 版:使用 Unicode UTF-8 提供全球语言支持」and restart the PC;
      3. Run the code below in cmd via `chcp 65001 & java -Dfile.encoding=UTF-8 Main`;
      4. Run the code below in cmd via `chcp 936 & java -Dfile.encoding=GBK Main`;

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The garbled characters should be 「系统找不到指定的路径。」 or "The system cannot find the path specified."

      ACTUAL -
      Both results are all:

      Exception in thread "main" java.io.IOException: 绯荤粺鎵句笉鍒版寚瀹氱殑璺緞銆?
      at java.io.WinNTFileSystem.createFileExclusively(Native Method)
      at java.io.File.createNewFile(File.java:1012)
      at Main.main(Main.java:5)

      ---------- BEGIN SOURCE ----------
      import java.io.File;

      public class Main {
          public static void main(String[] args) throws Throwable {
              new File("a/b/c").createNewFile(); // Set an invalid path.
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            jlu Justin Lu
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: