UTF-8 编码;只有一些日语字符没有被转换 [英] UTF-8 Encoding ; Only some Japanese characters are not getting converted

查看:29
本文介绍了UTF-8 编码;只有一些日语字符没有被转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 Jersey Web 服务 获取参数值作为参数,它是日语字符.

I am getting the parameter value as parameter from the Jersey Web Service, which is in Japaneses characters.

这里,'japaneseString' 是包含日语字符的网络服务参数.

Here, 'japaneseString' is the web service parameter containing the characters in japanese language.

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

但是,我能够成功转换一些 sting 文字,而其中一些会产生问题.

However, I am able to convert a few sting literals successfully, while some of them are creating problems.

以下已成功转换:

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

虽然这些没有:

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

当我进一步调查时,我发现这两个字符串被转换成一些垃圾字符.

When I further investigated, i found that these 2 strings are getting converted in to some JUNK characters.

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

知道为什么有些日文字符没有正确转换吗?

Any idea why some of the japanese characters are not converted properly?

谢谢.

推荐答案

在 Tomcat(JVM) 启动时尝试使用 JVM 参数 file.encoding 将值设置为 UTF-8.例如:-Dfile.encoding=UTF-8

Try with JVM parameter file.encoding to set with value UTF-8 in startup of Tomcat(JVM). E.x.: -Dfile.encoding=UTF-8

这篇关于UTF-8 编码;只有一些日语字符没有被转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆