This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Java in General and the fly likes display/input/write Chinese Text in java Options. CP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "display/input/write Chinese Text in java Options. CP" Watch "display/input/write Chinese Text in java Options. CP" New topic

display/input/write Chinese Text in java Options. CP

Mike Anna
Ranch Hand

Joined: Jul 08, 2007
Posts: 117
Dear All,

I am trying to make a very simple java program, where I am trying to
display Chinese characters. I am trying to save them into a file (for
now, later into db2). However, I seem to make no progress at all.
I am completely lost with this one. I have googled and gone through a
lot of sites like :

I have downloaded the cyberbit.ttf into /jre/lib/fonts and updated the also. (I dont reallyknow if I need to do it though).
I have tried to compile with two different encoding options big5 and
gb2132 as well.
I have also tried to pick up a few unicodes from a site and tried ..
for ex.

String s = "\U+0061";

but this results in Illegale Escape Char. exception.

All I am trying to do is use a String reference, feed it with Chinese
text, which again I copied from a site, and then display it on the
console. Or even write it to a file.
I am lost in the maze of Unicode, UTF -8 etc.

Later on :
I tried to actually start working on the web app where this change is
I copied a chinese String from a website (pasted it in Word, and it
pasted fine).
Pasted it in the text box and saved this field. The value appears
gibberish in db2 ( I am sure the tables arent specified for UTF-8).
My app doesnt use any contentType or characterEncoding either.
Then when I retrieve this value, it comes as exact same gibberish as
in DB.
But, behold, when I change the encoding (view -> encoding -> chinese
(GB2312)) It displays the exact String that was inserted :-)
Then I add these lines in my Jsp.

<%@ page contentType="text/html; charset=GB2312" %>

so that I can make that chinese GB2312 as the default option. It does
that. (The default was Western European (ISO).
However now, it displays question marks (???) in that field.

What options can I have ?
I would be really glad if someone could lead me out of this.

Thanks in advance.


This is a crosspost, obviously, because I did not recieve help
Mike Anna
Ranch Hand

Joined: Jul 08, 2007
Posts: 117
Welcome to the BEST forum at JavaRanch - (of course this is just them two crazy bartenders talking ...)

Please... dont let the word fail....

I agree. Here's the link:
subject: display/input/write Chinese Text in java Options. CP
It's not a secret anymore!