jjazzboss commented on a change in pull request #2633:
URL: https://github.com/apache/netbeans/pull/2633#discussion_r553172464



##########
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:
       Sorry I don't understand what you mean. I will make the 2 
`Utf8ThenIsoCharset ` instances static. But the `UtfThenIsoDecoder` instances 
remain created on demand via Charset.newDecoder() and discarded right after 
loading, so I don't see the need to make `UtfThenIsoDecoder `stateful
   
   Note: my code is doing exactly the same as JDK's code...




----------------------------------------------------------------
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

Reply via email to