Qt和unicode转义字符串 [英] Qt and unicode escape string

查看:1401
本文介绍了Qt和unicode转义字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用信号和插槽从服务器数据中获取。这是插槽部分:

  QString文本(this-> reply-> readAll());  

问题是,文本变量将是unicode转义,例如:

  \\\н\\\е \\\п\\\а\\\р\\\ь\\\с\\\я;  - ) 

有没有办法转换?

解决方案

你尝试过:

  QString text = QString :: fromUtf8(this-> reply-> readAll()); 

http://doc.qt.io/qt-5/qstring.html#fromUtf8



假设它是Utf8,否则使用 fromUtf16


I'm getting from server data using signal and slot. Here is slot part:

QString text(this->reply->readAll());

Problem is, that in text variable will be unicode escape, for example:

\u043d\u0435 \u043f\u0430\u0440\u044c\u0441\u044f ;-)

Is there any way to convert this?

解决方案

Did you try:

QString text = QString::fromUtf8(this->reply->readAll());

http://doc.qt.io/qt-5/qstring.html#fromUtf8

Assuming it's Utf8, otherwise use fromUtf16

这篇关于Qt和unicode转义字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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