Author: lehmi
Date: Wed Sep 23 05:41:04 2026
New Revision: 1938450

Log:
PDFBOX-5660: remove no longer used code

Modified:
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
        Wed Sep 23 04:26:07 2026        (r1938449)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
        Wed Sep 23 05:41:04 2026        (r1938450)
@@ -18,13 +18,7 @@ package org.apache.pdfbox.pdfparser;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 
-import java.nio.ByteBuffer;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CodingErrorAction;
 import java.nio.charset.StandardCharsets;
 
 import org.apache.commons.logging.Log;
@@ -62,35 +56,12 @@ public abstract class BaseParser
 
     static final int MAX_LENGTH_LONG = Long.toString(Long.MAX_VALUE).length();
 
-    private static final Charset ALTERNATIVE_CHARSET;
-
     private static final int MAX_RECURSION_DEPTH = 500;
     private static final String MAX_RECUSRION_MSG = //
             "Reached maximum recursion depth " + 
Integer.toString(MAX_RECURSION_DEPTH);
     
     private int recursionDepth = 0;
 
-    static
-    {
-        Charset cs;
-        String charsetName = "Windows-1252";
-        try
-        {
-            cs = Charset.forName(charsetName);
-        }
-        catch (IllegalArgumentException | UnsupportedOperationException e)
-        {
-            cs = StandardCharsets.ISO_8859_1;
-            LOG.warn("Charset is not supported: " + charsetName + ", falling 
back to " + cs.name(), e);
-        }
-        ALTERNATIVE_CHARSET = cs;
-    }
-
-    // CharSetDecoders are not threadsafe so not static
-    private final CharsetDecoder utf8Decoder = 
StandardCharsets.UTF_8.newDecoder()
-            .onMalformedInput(CodingErrorAction.REPORT)
-            .onUnmappableCharacter(CodingErrorAction.REPORT);
-
     protected static final int E = 'e';
     protected static final int N = 'n';
     protected static final int D = 'd';
@@ -920,27 +891,6 @@ public abstract class BaseParser
     }
 
     /**
-     * Tries to decode the buffer cotent to an UTF-8 String.
-     * If that fails, tries the alternative Encoding.
-     * @param buffer the {@link ByteArrayOutputStream} containing the bytes to 
decode
-     * @return the decoded String
-     */
-    private String decodeBuffer(ByteArrayOutputStream buffer) throws 
UnsupportedEncodingException
-    {
-        try
-        {
-            return 
utf8Decoder.decode(ByteBuffer.wrap(buffer.toByteArray())).toString();
-        }
-        catch (CharacterCodingException e)
-        {
-            // some malformed PDFs don't use UTF-8 see PDFBOX-3347
-            LOG.debug("Buffer could not be decoded using 
StandardCharsets.UTF_8 - "
-                    + "trying " + ALTERNATIVE_CHARSET.name(), e);
-            return buffer.toString(ALTERNATIVE_CHARSET.name());
-        }
-    }
-
-    /**
      * This will parse a directory object from the stream.
      *
      * @return The parsed object.

Reply via email to