Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Decoding strings

843834Feb 17 2009 — edited Feb 19 2009
Hi there

I have a little problem with the getSubject() method in a Message object. It returns me some '???' instead of a normal '-' (dash). I think it is an encoding problem but I'm not sure. I tried the same message on another Mail server (first I tried on Zimbra, then on Exchange) and I get then some strange squars instead of the dash. Anyway, if I look for the IMAP messages which JavaMail sends when I access the getSubject-method I see that there is my dash. In other words, the response of the mail server is correct. Is it possible that JavaMail messes up something internally?

Here is my code I'm using:
	        IMAPFolder fz = (IMAPFolder) zStore.getDefaultFolder().getFolder("inbox/save");
		Message[] msgs = f.getMessages();

		FetchProfile fp = new FetchProfile();
		fp.add(UIDFolder.FetchProfileItem.FLAGS);
		fp.add(IMAPFolder.FetchProfileItem.SIZE);
		fp.add(UIDFolder.FetchProfileItem.UID);

		f.fetch(msgs, fp);

		System.out.println("Subject: " + msgs[0].getSubject());
This is the IMAP response which shows me JavaMail in the debug mode:
A7 FETCH 1 (ENVELOPE INTERNALDATE RFC822.SIZE)
* 1 FETCH (ENVELOPE ("Sat, 31 Jan 2009 23:07:38 +0800" {55}
Una potenzialita piccola &ndash; noi lo possiamo risolvere  (("Roxie Ochocki" NIL "zwmbelle" "croston-engineering.co.uk")) (("Roxie Ochocki" NIL "zwmbelle" "croston-engineering.co.uk")) (("Roxie Ochocki" NIL "zwmbelle" "croston-engineering.co.uk")) (("..." NIL "..." "...")) NIL NIL NIL "<001501c983f8$b5d65360$058a9f6c@MYCHAT1F75848B>") INTERNALDATE "31-Jan-2005 18:27:51 +0100" RFC822.SIZE 3259)
A7 OK FETCH completed.
As you can see the subject contains a dash (it is the thing that begins with 'una potenzialita piccola...').

The output of the getSubject method is something like:
Subject: Una potenzialita piccola รข&#128;&#147; noi lo possiamo risolvere 
Any suggestions how to solve this problem?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 19 2009
Added on Feb 17 2009
6 comments
203 views