Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6476179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:47:34+00:00 2026-05-25T06:47:34+00:00

I have a text with quoted-printables . Here is an example of such a

  • 0

I have a text with quoted-printables. Here is an example of such a text (from a wikipedia article):

If you believe that truth=3Dbeauty, then surely=20=
mathematics is the most beautiful branch of philosophy.

I am looking for a Java class, which decode the encoded form to chars, e.g., =20 to a space.

UPDATE: Thanks to The Elite Gentleman, I know that I need to use QuotedPrintableCodec:

import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.net.QuotedPrintableCodec;
import org.junit.Test;

public class QuotedPrintableCodecTest { 
private static final String TXT =  "If you believe that truth=3Dbeauty, then surely=20=mathematics is the most beautiful branch of philosophy.";

    @Test
    public void processSimpleText() throws DecoderException
    {
        QuotedPrintableCodec.decodeQuotedPrintable( TXT.getBytes() );           
    }
}   

However I keep getting the following exception:

org.apache.commons.codec.DecoderException: Invalid URL encoding: not a valid digit (radix 16): 109
    at org.apache.commons.codec.net.Utils.digit16(Utils.java:44)
    at org.apache.commons.codec.net.QuotedPrintableCodec.decodeQuotedPrintable(QuotedPrintableCodec.java:186)

What am I doing wrong?

UPDATE 2: I have found this question @ SO and learn about MimeUtility:

import javax.mail.MessagingException;
import javax.mail.internet.MimeUtility;

public class QuotedPrintableCodecTest {
    private static final String TXT =  "If you believe that truth=3Dbeauty, then surely=20= mathematics is the most beautiful branch of philosophy.";

    @Test
    public void processSimpleText() throws MessagingException, IOException  
    {
        InputStream is = new ByteArrayInputStream(TXT.getBytes());

            BufferedReader br = new BufferedReader ( new InputStreamReader(  MimeUtility.decode(is, "quoted-printable") ));         
            StringWriter writer = new StringWriter(); 

            String line;
            while( (line = br.readLine() ) != null )
            {
                writer.append(line);
            }
            System.out.println("INPUT:  "  + TXT);
            System.out.println("OUTPUT: " +  writer.toString() );       
    }
    }

However the output still is not perfect, it contains ‘=’ :

INPUT:  If you believe that truth=3Dbeauty, then surely=20= mathematics is the most beautiful branch of philosophy.
OUTPUT: If you believe that truth=beauty, then surely = mathematics is the most beautiful branch of philosophy.

Now what am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:47:35+00:00Added an answer on May 25, 2026 at 6:47 am

    Apache Commons Codec QuotedPrintableCodec class does is the implementation of the RFC 1521 Quoted-Printable section.


    Update, Your quoted-printable string is wrong, as the example on Wikipedia uses Soft-line breaks.

    Soft-line breaks:

    Rule #5 (Soft Line Breaks): The Quoted-Printable encoding REQUIRES
          that encoded lines be no more than 76 characters long. If longer
          lines are to be encoded with the Quoted-Printable encoding, 'soft'
          line breaks must be used. An equal sign as the last character on a
          encoded line indicates such a non-significant ('soft') line break
          in the encoded text. Thus if the "raw" form of the line is a
          single unencoded line that says:
    
              Now's the time for all folk to come to the aid of
              their country.
    
          This can be represented, in the Quoted-Printable encoding, as
    
              Now's the time =
              for all folk to come=
               to the aid of their country.
    
          This provides a mechanism with which long lines are encoded in
          such a way as to be restored by the user agent.  The 76 character
          limit does not count the trailing CRLF, but counts all other
          characters, including any equal signs.
    

    So your text should be made as follows:

    private static final String CRLF = "\r\n";
    private static final String S = "If you believe that truth=3Dbeauty, then surely=20=" + CRLF + "mathematics is the most beautiful branch of philosophy.";
    

    The Javadoc clearly states:

    Rules #3, #4, and #5 of the quoted-printable spec are not implemented
    yet because the complete quoted-printable spec does not lend itself
    well into the byte[] oriented codec framework. Complete the codec once
    the steamable codec framework is ready. The motivation behind
    providing the codec in a partial form is that it can already come in
    handy for those applications that do not require quoted-printable line
    formatting (rules #3, #4, #5), for instance Q codec.

    And there is a bug logged for Apache QuotedPrintableCodec as it doesn’t support the soft-line breaks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text I am displaying in SIlverlight that is coming from a CMS
I have a string of text, which I then grab a URL from with
Hey, I have some text that is formatted like this: [quote]foo text[/quote] and I
I have a text file that have strings enclosed within double-quotes. I want to
I have some text that uses Unicode punctuation, like left double quote, right single
I have to remove quotes from a relatively large text file. I have looked
I have text within a paragraph tag that that fits snug on the bottom
I have a text file, I am told the delimiter is as quoted below.
I found the quoted text in Programming Python 3rd edition by Mark Lutz from
I have some php code that generates a random password. Next to a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.