Issue Details (XML | Word | Printable)

Key: EMAIL-54
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Piero Ottuzzi
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Email

[email] Add new class Charset

Created: 23/Feb/06 11:25 PM   Updated: 22/Feb/07 11:55 PM
Return to search
Component/s: None
Affects Version/s: 1.0
Fix Version/s: 1.1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works charset-support.patch 2007-02-08 07:00 PM Ben Speakmon 31 kB
Java Source File Charset.java 2006-02-23 11:29 PM Piero Ottuzzi 0.7 kB
Text File Email.java.patch 2006-02-23 11:27 PM Piero Ottuzzi 0.6 kB
Environment:
Operating System: other
Platform: Other
Issue Links:
Reference

Bugzilla Id: 38765
Resolution Date: 22/Feb/07 11:55 PM


 Description  « Hide
Add new class Charset the let the whole thing extensible and less error prone

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Piero Ottuzzi added a comment - 23/Feb/06 11:27 PM
Created an attachment (id=17777)
Patch for email to add method setCharset(Charset aCharset)

Piero Ottuzzi added a comment - 23/Feb/06 11:29 PM
Created an attachment (id=17778)
This is the new Charset class

dion gillard added a comment - 23/Feb/06 11:33 PM
Hmmm. JDK 14 introduced a java.nio.Charset class. Is that usable?

Piero Ottuzzi added a comment - 23/Feb/06 11:52 PM
(In reply to comment #3)
> Hmmm. JDK 14 introduced a java.nio.Charset class. Is that usable?

Yes, Charset would be usable but then we must use JDK 1.4 or above; in
Email.java in method createInternetAddress() you can read:
// Using this instead of new InternetAddress(email, name, [charset]) makes
// commons-email usable with javamail 1.2 / J2EE 1.3

If we go with javamail1.3/jdk1.4 then we can also fix easily COM-2527.


Piero Ottuzzi added a comment - 23/Feb/06 11:54 PM
Maybe we can go directly to commons-email 2.0 breaking API compatibility and
setting new requirements.

I think also we should release a 1.0.1 (or 1.1) with fixes committed so far.


Ben Speakmon added a comment - 21/Dec/06 07:12 PM
I've done some work on mail clients and servers with Java in the past – I would strongly recommend moving to JDK 1.4's Charset, as it saves all kinds of headaches like this.

I'm not sure if the current commons-email API could be preserved, so it may be a breaking change reserved for 2.0, but attempts to handle charsets with pre-1.4 tools is a truly Sisyphean task.

Releasing a 1.1 with current fixes is a great idea.


Ben Speakmon added a comment - 10/Jan/07 08:22 PM
Adding link to related issue.

Ben Speakmon added a comment - 08/Feb/07 07:00 PM
Attaching a patch and updated test cases for better charset support.
  • adds addTo(), addCc(), addReplyTo(), addBcc() overloads which take parameters (email, name, charset) and creates InternetAddresses that get encoded using the specified charset. This fixes EMAIL-25.
  • All charset names are now passed to java.nio.charset.Charset.forName(), which confirms that the requested charset is available in the current JVM and returns the canonical name for it. Invalid charset names will be detected and the proper exception thrown. This fixes EMAIL-14.
  • Finally, delegating charset handling to the JVM means we don't need a separate Charset class or create a need to maintain some kind of registry of correct names. A couple of comments on the charset issues request specific charsets; now, if the JVM supports it, we don't need to do anything else.

dion gillard added a comment - 22/Feb/07 11:55 PM
Applied the charset-support patch. Looks fine.