harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Zhang" <zhanghuang...@gmail.com>
Subject Re: [classlib][luni][charset]Strange behavior of UnicodeBig
Date Tue, 17 Oct 2006 08:36:38 GMT
On 10/17/06, Leo Li <liyilei1979@gmail.com> 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.

On 10/17/06, Tony Wu <wuyuehao@gmail.com> 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: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>
> --
> Leo Li
> China Software Development Lab, IBM
>
>


-- 
Best regards,
Andrew Zhang

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message