[Bug java/21068] New: String(strBytes, "UTF-16LE"); thorws java.io.UnsupportedEncodingException

gruni dot ca at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Apr 17 12:41:00 GMT 2005


The constructor String(strBytes, "UTF-16LE"); throws a
UnsupportedEncodingException which is not logical, becasue the Charset is
supported according to Charset.availableCharsets()
TestCase will follow. This is my output

Available Charsets are:
{ISO-8859-1=ISO-8859-1, US-ASCII=US-ASCII, UTF-16=UTF-16, UTF-16BE=UTF-16BE,
UTF-16LE=UTF-16LE, UTF-8=UTF-8}
Exception in thread "main" java.io.UnsupportedEncodingException: UTF-16LE
(java.lang.ClassNotFoundException: gnu.gcj.con
vert.Input_UnicodeLittle not found in
gnu.gcj.runtime.SystemClassLoader{urls=[file:.\], parent=gnu.gcj.runtime.VMClassLo
ader{urls=[core:/], parent=null}})
   at GcjStringTest.main(java.lang.String[])
(E:\2004-development\2005-extraextra\src\GcjStringTest.java)
   at ._main (C:\DOKUME~1\GRUNEW~1\LOKALE~1\Temp\ccM5baaa.i)

And accoring to the APIdocs:

String

public String(byte[] bytes,
              String charsetName)
       throws UnsupportedEncodingException

    Constructs a new String by decoding the specified array of bytes using the
specified charset. The length of the new String is a function of the charset,
and hence may not be equal to the length of the byte array.

    The behavior of this constructor when the given bytes are not valid in the
given charset is unspecified. The CharsetDecoder class should be used when more
control over the decoding process is required.

Parameters:
    bytes - the bytes to be decoded into characters
    charsetName - the name of a supported charset 
Throws:
    UnsupportedEncodingException - If the named charset is not supported
Since:
    JDK1.1 

The charset should be taken out of the Charsets class.

So ya this is a bug in my eyes.

Regards,

Andreas

-- 
           Summary: String(strBytes, "UTF-16LE"); thorws
                    java.io.UnsupportedEncodingException
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gruni dot ca at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21068



More information about the Gcc-bugs mailing list