你是在 windows 底下的吧?
std::string QString::toStdString() const
Returns a std::string object with the data contained in this QString. The Unicode data is converted into 8-bit characters using the toUtf8() function.
This method is mostly useful to pass a QString to a function that accepts a std::string object.
它转出来的 std::string 是 utf-8 编码的,如果你在 windows 底下想用,最好是这样子:
QString s;
cout << s.toLocal8Bit().toStdString() << endl;
先转成 gbk 类型的 QByteArray,再转成 std::string.
【 在 zhanghaoX (环顾四方有效) 的大作中提到: 】
: 得到的string 是乱码。
--
FROM 140.224.35.*