Jump to content
Chinese-Forums
  • Sign Up

Chinese Java Programming


darkprince

Recommended Posts

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?

Link to comment
Share on other sites

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?].....

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Guest
Click here to reply. Select text to quote.

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...