Yes, US-ASCII is the default if nothing is specified when parsing to a Message object. That's why MessageBuilder uses ISO8859-1 as default since it's a 8-bit superset of US-ASCII. If we use US-ASCII it will probably break some messages since sometimes 8-bit charsets are used even if no charset is specified. Using ISO8859-1 (or some other 8-bit encoding) will break those messages less than using US-ASCII in those cases.
Norman Maurer wrote: > Hi Stefano, > > i reread the rfc and you are right. I think we should use US-ASCII: > > http://tools.ietf.org/html/rfc2046 : > > > 4.1.2. Charset Parameter > > > > A critical parameter that may be specified in the Content-Type field > for "text/plain" data is the character set. This is specified with a > "charset" parameter, as in: > > Content-type: text/plain; charset=iso-8859-1 > > Unlike some other parameter values, the values of the charset > parameter are NOT case sensitive. The default character set, which > must be assumed in the absence of a charset parameter, is US-ASCII. > > > Any thoughts ? > > > > > Stefano Bagnara schrieb: > >> Are you sure the problem is that charsetName is null? >> Isn't instead this method called with "anychar" ? >> >> Wouldn't it be better to catch UnsupportedCharsetException and >> IllegalCharsetNameException around Charset.forName and simply leave c >> as null so that the following if will simply use the already present >> default? >> >> And, at the moment, I would leave the TODO there, because maybe >> ISO8859-1 is not the best default for everyone. >> >> I thought about using: >> new InputStreamReader(new ByteArrayInputStream(new byte[0]).getEncoding() >> But this would return UTF8 on system having a default file encoding >> set to UTF8 and maybe it is not good to parse email as UTF8 when >> unspecified. >> >> Any hint? >> >> Stefano >> >> [EMAIL PROTECTED] ha scritto: >> >>> Author: norman >>> Date: Mon Apr 23 05:11:16 2007 >>> New Revision: 531444 >>> >>> URL: http://svn.apache.org/viewvc?view=rev&rev=531444 >>> Log: >>> Use default charset of ISO8859-1 if charset could not retrived. Thx >>> to GX; -) >>> >>> Modified: >>> james/mime4j/trunk/src/main/java/org/mime4j/util/CharsetUtil.java >>> >>> Modified: >>> james/mime4j/trunk/src/main/java/org/mime4j/util/CharsetUtil.java >>> URL: >>> http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/mime4j/util/CharsetUtil.java?view=diff&rev=531444&r1=531443&r2=531444 >>> >>> ============================================================================== >>> >>> --- james/mime4j/trunk/src/main/java/org/mime4j/util/CharsetUtil.java >>> (original) >>> +++ james/mime4j/trunk/src/main/java/org/mime4j/util/CharsetUtil.java >>> Mon Apr 23 05:11:16 2007 >>> @@ -1119,10 +1119,11 @@ >>> } >>> >>> public static java.nio.charset.Charset getCharset(String >>> charsetName) { >>> + if(charsetName == null) charsetName = "ISO8859-1"; >>> + java.nio.charset.Charset c = >>> java.nio.charset.Charset.forName(charsetName); >>> if (c == null) { >>> - //TODO: Check what touse as default >>> c = java.nio.charset.Charset.forName("ISO8859-1"); >>> } >>> >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> !DSPAM:1,462ca850324321917326525! >> >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- Niklas Therning www.spamdrain.net --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]