This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

UTF-16 not supported?


Hi,

I have a piece of code here that attempts to use UTF-16BE encoding.

---sample--
public class encodingtest
{
  public static void main(String args[]) throws Exception
  {
    String encoding = "UTF-16BE";
    String str = "hello world";
    byte[] strbytes = str.getBytes(encoding);
    String newstr = new String(strbytes, encoding);
    System.out.println(newstr);
  }
}
--end sample---

The output of the program should be "hello world", which it is with
UTF-8.  But with UTF-16 or UTF-16BE, the output is a truncated string
"hell" or "hello".

I am using the the 3.1 release of gcc on my Mandrake 8.1 linux box.

I tried to wade through the relevant source code, and I think I am on
to something, but before I embarrass myself, I thought I'd post it here
and get some input.

thanks,
--Suresh



__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]