jjazzboss commented on a change in pull request #2633:
URL: https://github.com/apache/netbeans/pull/2633#discussion_r553618233
##########
File path: platform/openide.util/src/org/openide/util/NbBundle.java
##########
@@ -1458,4 +1475,90 @@ public DebugInputStream(InputStream base, int id,
boolean localizable) {
}
}
+
+
+ /**
+ * Local charset to decode using UTF-8 by default, but automatically
switching to ISO-8859-1 if UTF-8 decoding fails.
+ *
+ */
+ static private class UtfThenIsoCharset extends Charset {
+
+ private final boolean onlyUTF8;
+
+ /**
+ *
+ * @param acceptOnlyUTF8 If true there is no automatic switch to
ISO-8859-1 if UTF-8 decoding fails.
+ */
+ public UtfThenIsoCharset(boolean acceptOnlyUTF8) {
+ super(UtfThenIsoCharset.class.getCanonicalName(), null);
+ this.onlyUTF8 = acceptOnlyUTF8;
+ }
+
+ @Override
+ public boolean contains(Charset arg0) {
+ return false;
+ }
+
+ @Override
+ public CharsetDecoder newDecoder() {
+ return new UtfThenIsoDecoder(this, 1.0f, 1.0f);
+ }
+
+ @Override
+ public CharsetEncoder newEncoder() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ private final class UtfThenIsoDecoder extends CharsetDecoder {
Review comment:
I checked the CharsetDecoder API and I see is no inconsistency with the
code: you can switch decoder once on the ByteBuffer as long as you do it before
the end of input.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
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