darkprince Posted November 24, 2006 at 04:45 AM Report Posted November 24, 2006 at 04:45 AM Whenever i try and make an application in java with chinese text i always get blocks instead of UTF-8 chinese characters. Does anyone know how to fix this? Do i need to specify something in my main to look at the system locale ? I have seen a few applications such as javadict ( japanese kanji dictionary) and a few other chinese applications work on my PC so i know the fonts are there... Any ideas or pointers? Quote
YETIboy1230 Posted November 24, 2006 at 05:58 AM Report Posted November 24, 2006 at 05:58 AM Whenever i am developing applications mostly in Visual Studio2005 with c sharp.and i have encountered some font probs too with chinese font in the application....and i solved one in the option of edit memu but still remains some to be done so on my own guess that it is your [highlight]configuration of IDE [/highlight]should be responsible for the problem as you said you alread have chinese font installed .... i know nothing about developing app via java...no experience in the java IDE...so i think i am of only a little help.anyhow,you may try to turn to Codeguru ... PS:my os is chinese version ,but i do bump into fonts probs[can it be a bug/bugs?]..... Quote
imron Posted November 24, 2006 at 06:11 AM Report Posted November 24, 2006 at 06:11 AM Internally, Java uses utf-16 as the encoding. If you are reading utf-8 data, you will need to convert it into utf-16. Usually the best/easiest time to do this is when loading the data. It's been too long since I've done any Java programming to tell you the library to do this, but I'm sure there's a class somewhere that will do this for you. Quote
chinesetools Posted November 24, 2006 at 07:22 AM Report Posted November 24, 2006 at 07:22 AM Try the link http://www.chinesecomputing.com/programming/java.html for some ideas. Quote
trevelyan Posted November 24, 2006 at 08:53 AM Report Posted November 24, 2006 at 08:53 AM I remember running into this issue a while ago. When you find the specific solution an updated post here would be really welcome. Quote
novemberfog Posted November 25, 2006 at 01:42 AM Report Posted November 25, 2006 at 01:42 AM Look at that page that chinesetools linked. What I had to do to enable Chinese output on (Japanese Windows XP and English OS X) was to add an initialization function that looped through all of the fonts and found a font that supported Chinese. The code to do so is listed on that webpage. I suppose if you know the name of the font you could directly use it. Seems like there should be a more elegant way...but I am not aware of it. Quote
darkprince Posted November 25, 2006 at 09:17 AM Author Report Posted November 25, 2006 at 09:17 AM Look at that page that chinesetools linked. What I had to do to enable Chinese output on (Japanese Windows XP and English OS X) was to add an initialization function that looped through all of the fonts and found a font that supported Chinese. The code to do so is listed on that webpage. I suppose if you know the name of the font you could directly use it. Seems like there should be a more elegant way...but I am not aware of it Humm this does sound very hacky :S p.s i don't use windows Quote
novemberfog Posted November 26, 2006 at 04:46 AM Report Posted November 26, 2006 at 04:46 AM Well, I have not tried it on Linux or Solaris yet, but in OS X I had to use the font hack as well. I suppose you are on Linux? Are you trying to write X Window applications, or console programs? If you are using X Windows, you could try and set your default fonts to Chinese fonts perhaps? Quote
darkprince Posted November 26, 2006 at 08:02 AM Author Report Posted November 26, 2006 at 08:02 AM No, i'm not using Linux ,,, The point here is really - the OS SHOULD be irrelevant - this is the whole point of java. I can't believe such a simple thing is so difficult/hacky - shame on sun! Quote
Recommended Posts
Join the conversation
You can post now and select your username and password later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.