如何使用 QNetworkAccessManager POST Unicode 数据
我用 Unicode 数据填充了 QString 对象,并尝试使用 QNetworkAcccessManager.post 方法发送它,在服务器中我收到了一些 ??????而不是 Unicode 字符,但 JSON 格式在服务器上有效(我以这种格式发送数据)。然后我在发送之前使用了 QString.toUtf8 方法,服务器上有一些奇怪的字符(可能是正确的),但 JSON 格式无效,这意味着 Rails 框架的 JSON 解码器功能没有解析它。你能帮助我吗?
I filled a QString object with Unicode data and tried to send it with QNetworkAcccessManager.post method and in server I received some ?????? instead of Unicode characters but the JSON format was valid on server (I send data in this format). Then I used QString.toUtf8 method before sending and there was some strange characters (maybe correct ones) on server but JSON format was not valid, it means JSON decoder function of Rails framework didn't parse it. Can you help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 toUtf8() 将字符串转换为 QByteArray,然后使用 post 在这里工作。
对我来说,这更像是服务器问题而不是客户端问题。为了证明这一点,您可以:
此外,您应该说明您正在使用哪个版本的Qt,它可能有助于重现。
Converting your string to QByteArray using toUtf8() and then using post is working here.
For me, it's rather a server issue than a client one. To prove it, you can:
Moreover, you should state which version of Qt you're using, it might help reproduce.