hex encoding
diff --git a/src/main/java/org/apache/maven/shared/archiver/PomPropertiesUtil.java b/src/main/java/org/apache/maven/shared/archiver/PomPropertiesUtil.java
index 439771a..131ea14 100644
--- a/src/main/java/org/apache/maven/shared/archiver/PomPropertiesUtil.java
+++ b/src/main/java/org/apache/maven/shared/archiver/PomPropertiesUtil.java
@@ -98,7 +98,7 @@
|| c == '\\') { // backslash escape
sb.append('\\');
sb.append(c);
- } else if (c < 256) { // 8859-1
+ } else if (c < 128) { // ASCII
sb.append(c);
} else {
sb.append(hexEncode(c));
@@ -107,14 +107,6 @@
return sb.toString();
}
- private static String hexEncode(char c) {
- String hexString = "\\u" + Integer.toHexString(c).toUpperCase(Locale.ENGLISH);
- while (hexString.length() < 4) {
- hexString = '0' + hexString;
- }
- return hexString;
- }
-
private static String escapeValue(String s) {
StringBuilder sb = new StringBuilder(s.length());
boolean atBeginning = true;
@@ -126,7 +118,7 @@
sb.append('\\');
sb.append(c);
atBeginning = false;
- } else if (c < 256) { // 8859-1
+ } else if (c < 128) { // ASCII
sb.append(c);
atBeginning = false;
} else {
@@ -137,6 +129,14 @@
return sb.toString();
}
+ private static String hexEncode(char c) {
+ String hexString = Integer.toHexString(c).toUpperCase(Locale.ENGLISH);
+ while (hexString.length() < 4) {
+ hexString = '0' + hexString;
+ }
+ return "\\u" + hexString;
+ }
+
/**
* Creates the pom.properties file.
*
diff --git a/src/test/java/org/apache/maven/shared/archiver/PomPropertiesUtilTest.java b/src/test/java/org/apache/maven/shared/archiver/PomPropertiesUtilTest.java
index d8191c6..c1dc57e 100644
--- a/src/test/java/org/apache/maven/shared/archiver/PomPropertiesUtilTest.java
+++ b/src/test/java/org/apache/maven/shared/archiver/PomPropertiesUtilTest.java
@@ -91,6 +91,7 @@
out.write("a\\u0020key\\u0020with\\u0009whitespace=value\\u0020with\\u0009whitespace\n");
out.write("zkey=value with \\\\ not at end of line\n");
out.write("ykey=\\tvalue with whitespace at beginning\n");
+ out.write("xkey=\\u00E9\\u00FC\\u00E5\n");
}
util.createPomProperties(
@@ -109,15 +110,17 @@
assertEquals("value with\twhitespace", actual.getProperty("a key with\twhitespace"));
assertEquals("value with \\ not at end of line", actual.getProperty("zkey"));
assertEquals("\tvalue with whitespace at beginning", actual.getProperty("ykey"));
+ assertEquals("éüå", actual.getProperty("xkey"));
// Now read the file directly to check for alphabetical order and encoding
List<String> contents = Files.readAllLines(pomPropertiesFile, StandardCharsets.ISO_8859_1);
- assertEquals(6, contents.size());
+ assertEquals(7, contents.size());
assertEquals("a\\ key\\ with\\\twhitespace=value with\twhitespace", contents.get(0));
assertEquals("artifactId=\\u3053\\u3093\\u306B\\u3061\\u306F", contents.get(1));
assertEquals("groupId=org.foo", contents.get(2));
assertEquals("version=2.1.5", contents.get(3));
- assertEquals("ykey=\\\tvalue with whitespace at beginning", contents.get(4));
- assertEquals("zkey=value with \\\\ not at end of line", contents.get(5));
+ assertEquals("xkey=\\u00E9\\u00FC\\u00E5", contents.get(4));
+ assertEquals("ykey=\\\tvalue with whitespace at beginning", contents.get(5));
+ assertEquals("zkey=value with \\\\ not at end of line", contents.get(6));
}
}