我試着用下面的代碼轉換:如何TBuf8轉換爲QString的
template< unsigned int size >
static QString
TBuf82QString(const TBuf8<size> &buf)
{
return QString::fromUtf16(
reinterpret_cast<unsigned short*>(
const_cast<TUint8*>(
buf.Ptr())), buf.Length());
}
但它總是返回類似?????b
。
編輯:改變的代碼示例
是否上述工作的代碼,如果QT_NO_UNICODE定義? – James
它似乎甚至沒有編譯。 – Gerstmann
TBuf8中存儲了什麼?在那裏真正的字節順序是否真的有UTF16字符?它是否以2個零字節結束? – hmuelner