Skip to content

native-image windows shows garbage on console output UTF-8 text #2492

@matutet-ust

Description

@matutet-ust

Describe the issue
Windows console output shows garbage when using native-image but looks well when running using the JVM.

Steps to reproduce the issue

  1. Create a simple java code containing some international chars and the save it using UTF-8 encoding
public class Main {
    public static void main(String[] args) {
        System.out.println("UTF-8 text with some international chars:");
        System.out.println("äëïöü áéíóú àèiòù Ññ Çç €");
    }
}
  1. Compile and run the code using GraalVM. Output text looks well.
C:\tmp>java -version
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)

C:\tmp>javac -encoding utf8 Main.java

C:\tmp>java Main
UTF-8 text with some international chars:
äëïöü áéíóú àèiòù Ññ Çç ?
  1. Build native-image
C:\tmp>native-image Main
[main:7016]    classlist:   1,402.34 ms,  0.96 GB
[main:7016]        (cap):   2,629.87 ms,  0.96 GB
[main:7016]        setup:   4,151.39 ms,  0.96 GB
[main:7016]     (clinit):     131.62 ms,  1.21 GB
[main:7016]   (typeflow):   4,459.82 ms,  1.21 GB
[main:7016]    (objects):   3,230.77 ms,  1.21 GB
[main:7016]   (features):     237.91 ms,  1.21 GB
[main:7016]     analysis:   8,221.80 ms,  1.21 GB
[main:7016]     universe:     261.23 ms,  1.21 GB
[main:7016]      (parse):     940.52 ms,  1.21 GB
[main:7016]     (inline):     902.42 ms,  1.66 GB
[main:7016]    (compile):   5,910.52 ms,  2.27 GB
[main:7016]      compile:   8,136.16 ms,  2.27 GB
[main:7016]        image:     821.51 ms,  2.27 GB
[main:7016]        write:     319.91 ms,  2.27 GB
[main:7016]      [total]:  23,531.82 ms,  2.27 GB
  1. When running the "main.exe", garbage is shown
C:\tmp>main.exe
UTF-8 text with some international chars:
õÙ´÷³ ßÚݾ· ÓÞi‗¨ б Ãþ Ç

Describe GraalVM and your environment:

  • GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
  • JDK major version: 11
  • OS: Windows 10
  • Architecture: AMD64
  • Windows console codepage: 850 (chcp command)
  • Windows SDK: Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28614 for x64

More details

  • Same behaviour with GraalVM CE 20.0.0. or building native-image using the -H:+AddAllCharsets option.

  • Note the missing "€" in the JVM output. I think this is because MS-DOS CP 850 does not have the € (Euro symbol) and the JVM translates it to the "?" char.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions