法语口音给出“????>”在使用正确的Charset(Java)的HTTP响应中
调用返回法语句子的 API,即使字符集定义良好(application/json;charset=iso-8859- 1)。
使用邮递员或我的网络浏览器,我没有遇到任何问题。 我还尝试使用 Content-Type
标头调用 API,标头的值为 application/json;charset=UTF-8
或 application/json;charset=iso -8859-1
但问题仍然相同。 有什么想法吗?
response.getBody()
给出:
{"sentences":[{"fr_value":"il �tait loin","dz_value":"kaan b3id","additional_information":{"personal_prounoun":"HE","verb":"�tre","adjective":"loin","tense":"pass�"}}],"count":1}
new String(response.getBody().getBytes(StandardCharsets.UTF_8))
给出完全相同的结果。
我正在使用 scribejava。
Calling an API that returns french sentences, all the accented characters are displayed like <?>
in my java code, even if the charset is well defined (application/json;charset=iso-8859-1).
Using postman or my web browser, I don't face any problem.
I also tried to call the API with a Content-Type
header with the value application/json;charset=UTF-8
or application/json;charset=iso-8859-1
but the problem remains the same.
Any idea ?
response.getBody()
gives:
{"sentences":[{"fr_value":"il �tait loin","dz_value":"kaan b3id","additional_information":{"personal_prounoun":"HE","verb":"�tre","adjective":"loin","tense":"pass�"}}],"count":1}
new String(response.getBody().getBytes(StandardCharsets.UTF_8))
gives exactly the same.
I'm using scribejava.
Edit: even saving the response in a file and opening it with NotePad++, the result is similar:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将其阅读为ISO-8859-1。不知道那是什么,因为我不知道你在做什么。我的 https://technojeeves.com/indexnojeeves.com/index.php/alliasjava1/51/51/51/51/51 - transcode in-java 很有帮助。与WGET:
WGET -O- us-central1-dz-dialect-api.cl…| xcode -ie latin1
(我制作了'xcode'来调用该Java应用程序)You need to read it as ISO-8859-1. Not sure what then as I don't know what you're doing. My https://technojeeves.com/index.php/aliasjava1/51-transcode-in-java is helpful. With wget:
wget -O - us-central1-dz-dialect-api.cl… | xcode -ie Latin1
(I made 'xcode' to invoke that Java app)使用以下代码解决的问题:
Problem solved using the following code :