--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: gcj-4.1: UTF-16 endianness differs between gcj and Sun JDK
- From: Marcus Better <marcus@better.se>
- Date: Thu, 7 Sep 2006 19:17:47 +0200
- Message-id: <200609071717.k87HHlON005261@kakmonster.int.dactylis.com>
Package: gcj-4.1
Version: 4.1.1-10
Severity: normal
This program gives different results with Sun's JDK (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.
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-1-686
Locale: LANG=sv_SE.UTF-8, LC_CTYPE=sv_SE.UTF-8 (charmap=UTF-8)
Versions of packages gcj-4.1 depends on:
ii gcc-4.1 4.1.1-9 The GNU C compiler
ii gcj-4.1-base 4.1.1-10 The GNU Compiler Collection (gcj b
ii gij-4.1 4.1.1-10 The GNU Java bytecode interpreter
ii java-common 0.25 Base of all Java packages
ii libc6 2.3.6.ds1-4 GNU C Library: Shared libraries
ii libc6-dev 2.3.6.ds1-4 GNU C Library: Development Librari
ii libgcc1 1:4.1.1-9 GCC support library
ii libgcj7 4.1.1-10 Java runtime library for use with
ii libgcj7-dev 4.1.1-10 Java development headers and stati
ii libgcj7-jar 4.1.1-10 Java runtime library for use with
ii zlib1g 1:1.2.3-13 compression library - runtime
Versions of packages gcj-4.1 recommends:
ii fastjar 1:4.1.1-11 Jar creation utility
-- no debconf information
--- End Message ---