james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Warski <a...@warski.org>
Subject Decoding an attachment filename sent from Mail.app using DecoderUtil.decodeEncodedWords
Date Wed, 20 Apr 2011 12:54:20 GMT
Hello,

I am trying to decode a filename of an attachment sent with Mail.app. Originally, the file
is named "Żółw.rtf" (polish for Turtle.rtf).
The headers are:

--Apple-Mail-19-721116558
Content-Disposition: attachment;
   filename*=utf-8''Z%CC%87o%CC%81%C5%82w.rtf
Content-Type: text/rtf;
   x-unix-mode=0644;
   name="=?utf-8?Q?Z=CC=87o=CC=81=C5=82w=2Ertf?="
Content-Transfer-Encoding: 7bit

So the corresponding javax.mail.Part.getFileName() returns "=?utf-8?Q?Z=CC=87o=CC=81=C5=82w=2Ertf?=".

I tried decoding both with mime4j's DecoderUtil.decodeEncodedWords and JavaMail's MimeUtility.decodeText
but the result is: "Żółw.rtf". Clearly not the original :).

For comparison, MimeUtility.encodeText returns:
=?UTF-8?Q?=C5=BB=C3=B3=C5=82w.rtf?=
in contrast to:
=?utf-8?Q?Z=CC=87o=CC=81=C5=82w=2Ertf?=
coming from the e-mail.

According to my research, the letter "Ż" can be encoded in two ways: either as a single letter
or as "Z" + above-dot. MimeUtility.encodeText uses the former, Mail.app the latter.

Is there some way to properly decode the filename?

Thanks!

-- 
Adam Warski
http://www.warski.org
http://www.softwaremill.eu





Mime
View raw message