File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
Author

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 :


http://www.mandarintools.com/javaconverter.html
http://www.chinesecomputing.com/programming/java.html
http://forum.java.sun.com/thread.jspa?threadID=442220&messageID=1995079
http://www.linuxforum.net/chinese/develop/java.html
http://java.sun.com/docs/books/tutorial/i18n/locale/services.html


I have downloaded the cyberbit.ttf into /jre/lib/fonts and updated the
fonts.properties 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
intended.
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" %>
request.setCharacterEncoding("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.


Rgds,


This is a crosspost, obviously, because I did not recieve help
elsewhere.
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....

:roll:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: display/input/write Chinese Text in java Options. CP
 
Similar Threads
What underflow and overflow occures?
Hide Source Code in Struts
very hard question
Getting error while compiling
Displaying Binary Data Fetched with AJAX