Thanks Tim. That's the better way.
And ICU supports the "unicodebig" encoding. Try this:
Charset charset = CharsetICU.forNameICU("UnicodeBig");
System.out.println(charset);
It pass and return "UTF-16".
On Fri, May 15, 2009 at 12:54 AM, Tim Ellison (JIRA) <[email protected]>wrote:
>
> [
> https://issues.apache.org/jira/browse/HARMONY-4196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12709466#action_12709466]
>
> Tim Ellison commented on HARMONY-4196:
> --------------------------------------
>
> I think that option (2) above is a better solution, but it depends which
> charset provider we are talking about.
>
> For the built-in provider it should be sufficient to add:
>
> Index: src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java
> ===================================================================
> --- src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java
> (revision 774723)
> +++ src/main/java/org/apache/harmony/niochar/CharsetProviderImpl.java
> (working copy)
> @@ -320,7 +320,9 @@
>
> { "UTF_16", null,new String[] { "UTF-16",
> "UTF16",
> - "UTF_16" } },
> + "UTF_16",
> + "UnicodeLittle",
> + "UnicodeBig" } },
>
> { "UTF_16LE", null,new String[] { "UTF-16LE",
> "X-UTF-16LE",
>
>
> But I'd have to look a bit closer to see what it takes to add an alias to
> ICU providers.
>
>
> > [classlib][luni] InputStreamReader can't handle UnicodeBig encoding
> > -------------------------------------------------------------------
> >
> > Key: HARMONY-4196
> > URL: https://issues.apache.org/jira/browse/HARMONY-4196
> > Project: Harmony
> > Issue Type: Bug
> > Components: Classlib
> > Reporter: Vasily Zakharov
> > Assignee: Alexei Zakharov
> > Priority: Minor
> > Attachments: Harmony-4196-InputStreamReader_diagnostics.patch,
> HARMONY-4196.diff
> >
> >
> > Consider the following simple test:
> > import java.io.*;
> > public class Test {
> > public static void main(String[] args) {
> > try {
> > new InputStreamReader(new ByteArrayInputStream(new byte[]
> {(byte) 0xFE, (byte) 0xFF}), "UnicodeBig");
> > System.out.println("SUCCESS");
> > } catch (Throwable e) {
> > System.out.println("FAIL:");
> > e.printStackTrace(System.out);
> > }
> > }
> > }
> > Output on RI:
> > SUCCESS
> > Output on Harmony (both DRL VM and IBM VM):
> > FAIL:
> > java.io.UnsupportedEncodingException
> > at java.io.InputStreamReader.<init>(InputStreamReader.java:104)
> > at Test.main(Test.java:6)
> > Additional investigation shows that the cause for this exception is:
> > java.nio.charset.UnsupportedCharsetException: The unsupported charset
> name is "UnicodeBig".
> > at java.nio.charset.Charset.forName(Charset.java:564)
> > at java.io.InputStreamReader.<init>(InputStreamReader.java:99)
> > at Test.main(Test.java:5)
> > Interesting point is, the direct call to Charset.forName("UnicodeBig")
> causes the same exception on RI also.
> > So it seems the problem is not in Charset but in InputStreamReader
> itself.
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>
--
Yours sincerely,
Charles Lee