0
QString을 뒤 바꿔주는 간단한 코드가 있습니다. 나는 다음과 같은 단위 테스트를 할 때QTestLib 결과가 프로그램 출력과 다릅니다
"¿como estás?" : "?sátse omoc¿"
그러나, (QTestLib 사용) : 예상대로 나는 비 ASCII 문자를 사용하여 명령 줄에서 입력 텍스트는 상황이 갈
const QString reverse_qstring(const QString& str_in)
{
QString out;
Q_FOREACH(const QChar c, str_in) {
out.push_front(c);
}
return out;
}
QCOMPARE(reverse_qstring(QString("¿como estás?")), QString("?sátse omoc¿"));
내가 얻을 :
FAIL! : program::test_qstring() Compared values are not the same
Actual (reverse_qstring(QString("??como est??s?"))): ?s??tse omoc??
Expected (QString("?s??tse omoc??")): ?s??tse omoc??
아이디어가 있으십니까? http://doc.qt.io/qt-4.8/qtextcodec.html#setCodecForCStrings
또는 대신이를 사용할 수 있습니다 :
조각! 유니 코드 매핑이 너무 많지는 않았 으면 좋겠다. – taynaron