[Bug libgcj/28977] New: UTF-16 endianness differs between gcj and Sun JDK
marcus at better dot se
gcc-bugzilla@gcc.gnu.org
Thu Sep 7 18:26:00 GMT 2006
This program gives different results with Sun's JDK (Debian sun-java5-jdk
1.5.0-08-1) and gcj:
======== Test.java ========
import java.io.*;
public class Test
{
public static void main(String[] args) throws java.io.IOException
{
OutputStreamWriter o = new OutputStreamWriter(System.out, "UTF-16");
o.write("Hello!");
o.flush();
}
}
===========================
According to Sun's API docs
http://java.sun.com/j2se/1.5.0/docs/api/java/nio/charset/Charset.html
the UTF-16 encoding is supposed to default to big-endian. This is also
what I get when running with Sun's JVM:
00000000: feff 0048 0065 006c 006c 006f 0021 ...H.e.l.l.o.!
But when I run the same program with gij, I get little-endian output:
00000000: fffe 4800 6500 6c00 6c00 6f00 2100 ..H.e.l.l.o.!.
In both cases I executed the same .class file, compiled with the Sun
JDK.
The system is Debian i386 testing/unstable.
$ gij --version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20060729 (prerelease) (Debian 4.1.1-10)
This bug was also reported in the Debian bug-tracking system:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=386443
--
Summary: UTF-16 endianness differs between gcj and Sun JDK
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgcj
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: marcus at better dot se
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28977
More information about the Gcc-bugs
mailing list