Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Applets and the fly likes Multilingual support for Java applet (java.awt) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Multilingual support for Java applet (java.awt)" Watch "Multilingual support for Java applet (java.awt)" New topic
Author

Multilingual support for Java applet (java.awt)

janne jounivich
Ranch Hand

Joined: Jan 11, 2005
Posts: 45
Hey,

I am encountering the following kind of problem. I am trying to implement a chat applet that supports various languages such as korean, russian, chinese, japanese and scandinavian languages (characters �,�,�) etc.

The problem is that I am capable of producing text basically in any language (in a understable format so that on my own chat applet window everything gets outputted correctly) but others participating the chat aren't doing that. Instead of seeing real characters they see only question marks, ???.

What may be causing this?

Please help me out with this problem. I have already tested the following kind of approach like

String myUTF8=new String(Ed.getText().getBytes("ISO-8859-1"),"UTF-8")
but without success.

Br.
Janne


----
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
How are you transferring the characters between the applet and the chat server - are you explicitly using the same encoding everywhere, or do you have any code that uses the platform default encoding (which might be different on each applet client)?


Ping & DNS - my free Android networking tools app
janne jounivich
Ranch Hand

Joined: Jan 11, 2005
Posts: 45
Would you mind if I send you my Java code? It would be probably easier for you to tell what's wrong with the code than copy/pasting just some portions of code?

In case of yes, which address could I send the code?

Br,
Janne
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
Would you mind if I send you my Java code?

Actually, I would. We have the forums so that everyone can benefit and respond. Feel free to post a minimal excerpt of the code that exhibits the problem, and we can all take a look at it.
janne jounivich
Ranch Hand

Joined: Jan 11, 2005
Posts: 45
Hi Ulf,


In my client part of app in SocketHandler I am using

input = new BufferedReader(new InputStreamReader(cs.getInputStream(),"UTF-8"));
output = new PrintWriter(new OutputStreamWriter(cs.getOutputStream(),"UTF-8"));


and

in server part in ConnectionHandler I am using

input = new BufferedReader(new InputStreamReader(cs.getInputStream(),"UTF-8"));
output = new PrintWriter(new OutputStreamWriter(cs.getOutputStream(),"UTF-8"));

but still when debugging with the help of Java console, I get only
question marks instead of f.eg real characters. What could be the problem?

Br.
Janne
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
Make sure the Java Console is capable of properly displaying Unicode characters. Many text-based consoles are not.

Can you give an example of bytes that are sent correctly by one side, yet arrive garbled at the other side? What are the respective values?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
Please RespectYourCoranchersPrivacy and UseTheForumNotEmail.

I'll ask again:
Can you give an example of bytes that are sent correctly by one side, yet arrive garbled at the other side? What are the respective values?


If the bytes are received as they are sent, what encodings/decodings are applied when converting them to and from strings on both sides of the connection?

Feel free to post problematic code, but make sure to pare it down to the absolute minimum required to demonstrate the erroneous behavior.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multilingual support for Java applet (java.awt)