On 10/17/06, Tony Wu <[EMAIL PROTECTED]> wrote:
Thank you Andrew, I think I got the point. The j.l.String of RI uses the encoding of IO whereas Charset.forName use another of NIO.
exactly! And the new problem is shall we follow the spec[1] to support the two
suites of charset implemetation? I just have a look and find we does not support some Canonical Name for java.io and java.lang API such as UnicodeBigUnmarked,UnicodeLittleUnmarked,UnicodeBig,Unicodelittle,etc.
I think we have no choice because spec has explictly pointed out the basic charset name for java.io,java.lang and nio, which includes "UnicodeBig". So the problem left is how, not whether. :-) Mapping may solve this problem. We may map: 1. io/lang -> nio 2. nio -> io/lang 3. io/lang/nio -> icu BTW, does current nio.charset implementation support "UnicodeBig"? There're a little differences between "UnicodeBig" and "UTF-16 BE": UnicodeBig: Sixteen-bit Unicode Transformation Format, big-endian byte order, with byte-order mark UTF-16 BE: Sixteen-bit Unicode Transformation Format, big-endian byte order [1] http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html
On 10/17/06, Andrew Zhang <[EMAIL PROTECTED]> wrote: > On 10/17/06, Andrew Zhang <[EMAIL PROTECTED]> wrote: > > > > > > > > On 10/17/06, Leo Li <[EMAIL PROTECTED]> wrote: > > > > > > I think Harmony is more reasonable. > > > > > > As spec says, if Charset.forName("UnicodeBig") throws > > > .UnsupportedCharsetException then no support for the named charset is > > > available in this instance of the Java virtual machine. Then how can we > > > get > > > new String(b, "UnicodeBig") without throwing UnsupportedCharsetException > > > on > > > the same jvm? The spec for String(byte[] bytes,String charsetName) also > > > says > > > if the named charset is not supported, UnsupportedCharsetException > > > should be > > > thrown out. > > > > > > UNICODEBIG is a java alias for UTF-16BE. I think we'd better support such > > mapping in String and follow RI. > > > > You can find the encoding set from spec. [1] > > [1] http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html > > On 10/17/06, Tony Wu <[EMAIL PROTECTED]> wrote: > > > > > > > > Hi all, > > > > I found this when I tried to debug the failure tests of ant on > > > > harmony. Note the output of testcases below. > > > > > > > > import java.io.UnsupportedEncodingException; > > > > import java.nio.charset.Charset ; > > > > import junit.framework.TestCase; > > > > > > > > public class TestCharset extends TestCase { > > > > public void test1() throws UnsupportedEncodingException { > > > > byte[] b = new byte[] { 'a', 'b', 'c' }; > > > > String s = new String(b, "UnicodeBig"); > > > > assertEquals("abc", s); > > > > } > > > > > > > > public void test2() { > > > > Charset.forName("UnicodeBig"); > > > > } > > > > } > > > > > > > > RI: > > > > test1: junit.framework.ComparisonFailure: expected:<abc> but was:<> > > > > test2: java.nio.charset.UnsupportedCharsetException: UnicodeBig > > > > > > > > Harmony: > > > > test1:java.nio.charset.UnsupportedCharsetException: UnicodeBig > > > > test2: > > > > java.nio.charset.UnsupportedCharsetException: The unsupported charset > > > > name is "UnicodeBig" > > > > > > > > seems RI can recognize the *UnicodeBig* in Constructor of j.l.String, > > > > whereas Harmony does not support this alias at all. > > > > > > > > Do you have any concern about that? > > > > -- > > > > Tony Wu > > > > China Software Development Lab, IBM > > > > > > > > --------------------------------------------------------------------- > > > > Terms of use : http://incubator.apache.org/harmony/mailing.html > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > -- > > > Leo Li > > > China Software Development Lab, IBM > > > > > > > > > > > > -- > > Best regards, > > Andrew Zhang > > > > > -- > Best regards, > Andrew Zhang > > -- Tony Wu China Software Development Lab, IBM --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Best regards, Andrew Zhang