PDA

View Full Version : WCHAR and CHAR



halianka
9th February 2010, 18:59
in Visual studio there is the option in the compiler that you can convert WCHAR to char but i can't find it in QT... :confused:
So if there is no compiler option in QT what is the clean way to convert WCHAR to char and vice vesa?

franz
9th February 2010, 21:28
The way Visual studio handles unicode is flawed. Use QStrings instead. Have a look at the following static member functions (http://doc.trolltech.com/latest/qstring.html#static-public-members):
QString fromAscii ( const char * str, int size = -1 )
QString fromLatin1 ( const char * str, int size = -1 )
QString fromLocal8Bit ( const char * str, int size = -1 )
QString fromRawData ( const QChar * unicode, int size )
QString fromStdString ( const std::string & str )
QString fromStdWString ( const std::wstring & str )
QString fromUcs4 ( const uint * unicode, int size = -1 )
QString fromUtf8 ( const char * str, int size = -1 )
QString fromUtf16 ( const ushort * unicode, int size = -1 )
QString fromWCharArray ( const wchar_t * string, int size = -1 )