Sascha Szott created NETBEANS-1377:
--------------------------------------
Summary: weird encoding issue when reading keyboard input in Maven
project: input is provided ISO-8859-1 encoded
Key: NETBEANS-1377
URL: https://issues.apache.org/jira/browse/NETBEANS-1377
Project: NetBeans
Issue Type: Bug
Components: core, projects - Maven
Affects Versions: 9.0, 8.2
Environment: The behaviour was reproduced under Ubuntu and MacOS both
with NB 8.2 and 9.0
Reporter: Sascha Szott
I'm using Java's build-in class java.util.Scanner to read keyboard input (typed
in within Netbeans' Output window).
To accomplish this task a simple Java class is used:
{code}
package de.szott;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("output some non ASCII chars works properly: ä ö ü
ß");
System.out.print("give me some non ASCII chars, e.g. German umlauts: ");
Scanner input = new Scanner(System.in, "UTF-8");
System.out.println("input: " + input.nextLine());
input.close();
}
}
{code}
Running this class in Netbeans as a *Java project* leads to the expected result:
{noformat}
run:
output some non ASCII chars works properly: ä ö ü ß
give me some non ASCII chars, e.g. German umlauts: äöü
input: äöü
{noformat}
Running the same class as a *Maven project* in Netbeans (which uses the Maven
Exec Plugin internally) leads to erroneous behaviour:
{noformat}
[INFO] --- exec-maven-plugin:1.5.0:exec (default-cli) @ Bug ---
output some non ASCII chars works properly: ä ö ü ß
give me some non ASCII chars, e.g. German umlauts: äöü
input: ���
{noformat}
Netbeans IDE is running under Ubuntu 64Bit. Netbeans is using UTF-8 as default
encoding. The Maven project consists of the following pom.xml:
{code}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.szott</groupId>
<artifactId>UmlautTestWithMaven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
{code}
The output � (Unicode replacement character) indicates that the interpretation
of the input bytes as UTF-8 encoded is not appropriate. This confirms that
Netbeans or the Maven plugin in Netbeans does not provide keyboard input in
UTF-8 encoding to the running Java application.
A minor change to the simple program indicates that Netbeans seems to interpret
the keyboard input as ISO-8859-1 encoded when running as a Maven project:
{code}
Scanner input = new Scanner(System.in, "ISO-8859-1");
{code}
Output (when running as a Maven project):
{noformat}
[INFO] --- exec-maven-plugin:1.5.0:exec (default-cli) @ Bug ---
output some non ASCII chars works properly: ä ö ü ß
give me some non ASCII chars, e.g. German umlauts: äöü
input: äöü
{noformat}
Note that this approach does not work if characters are provided as input that
cannot be encoded in ISO-8859-1, e.g. the € character.
This indicates that the Maven plugin in Netbeans does not provide a full
Unicode support.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists