Skip to content

scrambled characters for the ± character when running on system with non-UTF8 encoding #709

@remkop

Description

@remkop

Related to #694: encoding issue;

CommandLine source code (UTF-8) contains

            CommandLine.RegexTransformer transformer = new CommandLine.RegexTransformer()
                    .addPattern("^-(\\w)$", "+$1", "±$1")
                    // ...

This shows scrambled characters for the ± character when compiling on a Japanese system

org.junit.ComparisonFailure: expected:<... --X:ツアjava1        [ ...
  -f, --X:ツアjava4         ...
  -g, -X:ツアjava5          ...
  -h, -XX:ツアjava6         ...
      --[no-]long        ...
  -n, --[no-]verbose-b   ...
      --[no-]verbose     ...
      -X:ツアjava2          ...
      -XX:ツアjava3 ]        ...
> but was:<... --X:ツアjava1        [...
  -f, --X:ツアjava4        ...
  -g, -X:ツアjava5         ...
  -h, -XX:ツアjava6        ...
      --[no-]long        ...
  -n, --[no-]verbose-b   ...
      --[no-]verbose     ...
      -X:ツアjava2         ...
      -XX:ツアjava3]        ...
>
	at org.junit.Assert.assertEquals(Assert.java:115)
	at org.junit.Assert.assertEquals(Assert.java:144)
	at picocli.NegatableOptionTest.testUsage(NegatableOptionTest.java:79)

This can be fixed by changing the build:

Index: build.gradle
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- build.gradle	(date 1559094279228)
+++ build.gradle	(date 1559094279228)
@@ -28,6 +28,9 @@
     targetCompatibility = !org.gradle.api.JavaVersion.current().isJava9Compatible() ?
             1.5 : org.gradle.api.JavaVersion.current().isJava11Compatible() ? 1.7 : 1.6
 
+    compileJava.options.encoding = "UTF-8"
+    compileTestJava.options.encoding = "UTF-8"
+
     repositories {
         jcenter()
     }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions