텍스트가 quoted-printables입니다. 당신이 진실 = 3Dbeauty, 그때 확실히 20 =
수학을 = 철학의 가장 아름다운 지점입니다 생각되면인용 가능한 문자를 인용 부호에서 문자로 디코딩하는 방법은 무엇입니까?
: 여기에 (A wikipedia article에서) 같은 텍스트의 예입니다.
나는 공간으로, 문자로 인코딩 된 양식을 디코딩 자바 클래스, 예를 들어, 대한 = 20을 찾고 있어요.
UPDATE : 엘리트 신사 덕분에, 내가 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());
}
}
그러나 나는 다음과 같은 예외가 점점 계속 :
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)
내가 잘못하고있는 중이 야 무엇을?
는 업데이트 2 : 나는 this question @ SO을 발견하고 배울 수있는 약 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());
}
}
, 그것은 '='가 포함
지금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.
내가 무슨 일을하고있는 중이 야 ?
답변을 주셔서 감사합니다. 불행히도 위키 피 디아 페이지에서 예제를 디코딩하려고하면 예외가 발생합니다. – Skarab
@Skarab, 코드 및 예외 스택 추적을 표시하지 않으면 예외가 발생했기 때문에 내 대답이 좋지 않다고 생각할 수 없습니다. 당신은 인용 가능한 문자들을 해독하는 클래스를 물었습니다. 그리고 저는 그것을 보여 줬습니다. –
@ 스카럽, 숙제 연습에 대한 글을 올렸습니다. 나는 지금 +1을 기대해야한다 :) –