Java – UTF-8 encoding; Only some Japanese characters have not been converted

I get the parameter value from Jersey web service as the parameter. The service is Japanese character

Here, 'Japanese string' is a web service parameter containing Japanese characters

String name = new String(japaneseString.getBytes(),"UTF-8");

However, I can successfully convert some sting text, and some of them will cause problems

The following conversion succeeded:

1) アップル
 2) 赤
 3) 世丕且且世两上与丑万丣丕且丗丕
 4) 世世丗丈

Although these are not:

1) ひほわれよう
 2) 存在する

When I investigated further, I found that the two strings were being converted into some junk characters

1) Input: ひほわれよう        Output : �?��?��?れよ�?�
 2) Input: 存在する            Output: 存在�?�る

Do you know why some Japanese characters are not converted correctly?

thank you.

Solution

Try using the JVM parameter file Encoding is set with the value UTF - 8 when Tomcat (JVM) starts E.x.: – Dfile. encoding = UTF-8

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>