在QT 5.4和C++中,我嘗試解碼具有unicode實體的字符串。Qt convert unicode entities
我有這樣的QString:
QString string = "file\u00d6\u00c7\u015e\u0130\u011e\u00dc\u0130\u00e7\u00f6\u015fi\u011f\u00fc\u0131.txt";
我想這個字符串轉換成這樣:fileÖÇŞİĞÜİçöşiğüı.txt
我試圖QString
的toUtf8
和fromUtf8
方法。還試圖逐字符解碼。
有沒有辦法通過使用Qt轉換它?
可能您的控制檯未配置爲打印Unicode。如果您在Windows提示符下執行,請嘗試這個http://stackoverflow.com/questions/2492077/output-unicode-strings-in-windows-console-app – KuramaYoko
謝謝。是的Windows控制檯也有unicode問題,但我需要在我的cpp代碼解碼。 – trante
您的字符串文字包含Unicode轉義符,可能不適合8位的字符。在al Qt平臺上,char是8位。你可能需要一個寬泛的文字:'L'file \ u00d6 \ u00c7 \ u015e \ u0130 ...「' – MSalters