Last active
December 20, 2015 05:39
-
-
Save kaspersorensen/6079742 to your computer and use it in GitHub Desktop.
UnicodeWriterEncodingIssue.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/core/src/main/java/org/apache/metamodel/util/UnicodeWriter.java b/core/src/main/java/org/apache/metamodel/util/UnicodeWriter.java | |
| index 4867b52..9a19267 100644 | |
| --- a/core/src/main/java/org/apache/metamodel/util/UnicodeWriter.java | |
| +++ b/core/src/main/java/org/apache/metamodel/util/UnicodeWriter.java | |
| @@ -164,22 +164,23 @@ public class UnicodeWriter extends Writer { | |
| String encoding) throws UnsupportedEncodingException, IOException { | |
| OutputStreamWriter writer = new OutputStreamWriter(outputStream, | |
| encoding); | |
| + | |
| + encoding = encoding.replaceAll("-", ""); | |
| // Write the proper BOM if they specified a Unicode encoding. | |
| // NOTE: Creating an OutputStreamWriter with encoding "UTF-16" | |
| // DOES write out the BOM; "UTF-16LE", "UTF-16BE", "UTF-32", "UTF-32LE" | |
| // and "UTF-32BE" don't. | |
| - if ("UTF-8".equalsIgnoreCase(encoding)) { | |
| + if ("UTF8".equalsIgnoreCase(encoding)) { | |
| outputStream.write(UTF8_BOM, 0, UTF8_BOM.length); | |
| - } else if ("UTF-16LE".equalsIgnoreCase(encoding)) { | |
| + } else if ("UTF16LE".equalsIgnoreCase(encoding)) { | |
| outputStream.write(UTF16LE_BOM, 0, UTF16LE_BOM.length); | |
| - } else if (/* "UTF-16".equalsIgnoreCase(encoding) || */ | |
| - "UTF-16BE".equalsIgnoreCase(encoding)) { | |
| + } else if ("UTF16BE".equalsIgnoreCase(encoding)) { | |
| outputStream.write(UTF16BE_BOM, 0, UTF16BE_BOM.length); | |
| - } else if ("UTF-32LE".equalsIgnoreCase(encoding)) { | |
| + } else if ("UTF32LE".equalsIgnoreCase(encoding)) { | |
| outputStream.write(UTF32LE_BOM, 0, UTF32LE_BOM.length); | |
| - } else if ("UTF-32".equalsIgnoreCase(encoding) | |
| - || "UTF-32BE".equalsIgnoreCase(encoding)) { | |
| + } else if ("UTF32".equalsIgnoreCase(encoding) | |
| + || "UTF32BE".equalsIgnoreCase(encoding)) { | |
| outputStream.write(UTF32BE_BOM, 0, UTF32BE_BOM.length); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment