Bernd Fondermann ha scritto:
The second "if" should not be needed anymore.
The javadoc suggests that the charset name is not "ISO8851-1" but
"ISO-8851-1" (which is also required to be supported by every
platform)
FWIW, J1.5 has Charset.defaultCharset() which is not applicable for 1.4.
The "new InputStreamReader(new ByteArrayInputStream(new
byte[0]).getEncoding()" I referred in the other reply should be the
workaround to get the same result.
Btw, do you think this is appropriate as the default charset to use to
decode messages encoded with an unknown format?
Your sentence "the second if should not be needed" made me think that an
empty charset should be treated as an unknown charset.
So if on unknown charset we simply let the runtime exceptions (
IllegalCharsetNameException/UnsupportedCharsetException to be raised why
don't we do the same on null/empty/wrong charset ?
Please note that I don't know who calls this CharsetUtil method, and how
they handle runtime exceptions (no time to check this now).
Stefano
Bernd
On 4/23/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]