-2

I got an application that coded with java.

the application have a same window that i can add some text and hit the send button. it is sending the test to a server and then print it there.

when i'm writing an English letter i have no problem.

when i'm writing Chinese letter , i can see it on the windows , but when hitting the send button the letter is changed to ??.

and the string that i'm sending to the server is ??.

any idea how i can add the Chinese support here ?

USer22999299
  • 5,284
  • 9
  • 46
  • 78
  • The code matters. Without code, we can't help. We don't know how you send the letters, how you read them at server-side, how you print/display them. – JB Nizet Nov 03 '13 at 08:36
  • as i saw on a Chinese operating system using the same tool sending the Chinese string to the server side and print the currently i was checking that via remote control. while using it on my computer i'm getting the ?? while sending it. so i'm sure it is related to the default string codec that java is getting some how from the operating system – USer22999299 Nov 03 '13 at 08:55
  • 1
    The "default string codec" of a java string (formally known as character encoding) is UTF-16 which supports Chinese characters. The two areas of your program which may be causing problems is the display font or the character encoding used during transmission. English systems tend to have a default font which doesn't include Chinese characters and if no font is specified java will just grab the default font and use it for rendering. If thats not the case, the problem may originate when the String itself is being mapped into bytes where an inappropriate character set discards Chinese characters. – initramfs Nov 03 '13 at 09:06
  • Ok , it is sound like the default string codec on the English system is not supported the Chinese characters. where i can change the default font/codec? – USer22999299 Nov 03 '13 at 09:09
  • When converting String to a byte[] you would normally use the method `getBytes()`. To specify a explicit character encoding to use (always good practice to do so), use the `getBytes("charset here")` method. E.g `getBytes("UTF-16")`. Changing the display font depends largely on how your GUI is designed. In the most basic case, if you are using a `JComponent`, calling the `setFont()` method with an appropriate font should do the trick. – initramfs Nov 03 '13 at 09:20
  • If you're so sure about the cause of the problem, why do you ask here? Why don't you provide the code as you've been asked to do? Voting to close. – JB Nizet Nov 03 '13 at 09:24
  • this is the problem , i'v got an 3-party application that i cannot to edit. i need somehow to be able to change on the operating system or the JVM the default font. Is there any way to do it? – USer22999299 Nov 03 '13 at 09:29
  • So why exactly did you post the problem? If you can't even fix the issue whats the use in trying to obtain an answer based on probable guesses (due to the lack of information/code. Which probably doesn't help the dev either). It is the developer's responsibility to fix his/her program, not yours. If its a fault of the application, there is nothing you can really do to fix it (not going into reverse-engineering here or some sort of hack here). – initramfs Nov 03 '13 at 09:31
  • that's what i was asking at the begging, i need to add chinese support to an existing application on the JVM it self / find a way to change the default font that the JVM is using , i didn't look for an a solution by changing the existing application. any information about how to do that? – USer22999299 Nov 03 '13 at 09:41

1 Answers1

0

by adding to the bat file -Dfile.encoding=GB2312 the java application support the Chinese char.

USer22999299
  • 5,284
  • 9
  • 46
  • 78