Play Framework WS从外部API丢失Unicode字符 [英] Play Framework WS losing unicode chars from external api
问题描述
我正在开发一个使用WS对外部api进行异步调用的播放应用程序,但我不知道为什么在消费时会丢失Unicode字符
I'm working on a play application that uses WS to make an asynchronous call to an external api and I can't figure out why I'm losing unicode chars when consuming
例如,如果他们的api产生类似以下内容的话:
for instance if they api is producing something like:
{ "title": "Plück, Franke" }
并使用以下命令调用api:
and make a call to the api with:
ws.url("http://example.org/stuff/").get().map { response =>
println(response.body)
Ok....
将打印以下内容:
{ "title":"Plück, Franke" }
我正在尝试查找是否需要将标头参数传递给WSRequest对象以保留字符集? setContentType的 WSRequest文档方法状态
I'm trying to find if there is a header argument that I need to be passing to the WSRequest object to preserve the character set? The WSRequest documentation for the setContentType method states
设置内容类型.如果请求正文是String,并且没有字符集 参数包含在内,则默认为UTF-8."
"Set the content type. If the request body is a String, and no charset parameter is included, then it will default to UTF-8."
我想念什么?
谢谢! AH
推荐答案
这是我使用的Play版本(2.6.3)中的一个错误,我已升级到2.6.7,并且所有问题都已得到纠正.
This was a bug in the version of Play I was using (2.6.3) I upgraded to 2.6.7 and all was remedied.
这篇关于Play Framework WS从外部API丢失Unicode字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!