Reputation: 1
I have text box and a button. I am entering Japanese characters like こんにちは in text box.
When I click on button email is sent with the text in text box.
But when email receive it displays some junk character instead Japanese characters.
Can anybody please tell me why this is happening?
Thanks in advance.
Upvotes: 0
Views: 2981
Reputation: 41
im not really sure if you are using java servlets but if you do, you can try this
request.setCharacterEncoding("UTF-8");
Upvotes: 0
Reputation: 15524
You should make sure that you are using a character set that supports Japanese characters, like Unicode.
For instance, when creating a String
object there is an overloaded constructor where you can specify character encoding:
byte[] utf8Characters = { /* UTF-8 encoded characters */ };
String s = new String(characters, "UTF-8"); // Decode bytes using UTF-8.
Also when converting Strings to bytes (ie when streaming data) you can use:
byte[] utf8EncodedBytes = s.getBytes("UTF-8"); // Encode to UTF-8.
If you do not specify character encoding it will default to some charset which might not support the characters you need.
Java Doc says: "The default charset is determined during virtual-machine startup and typically depends upon the locale and charset being used by the underlying operating system."
Upvotes: 1