Results 1 to 2 of 2

Thread: WCHAR and CHAR

  1. #1
    Join Date
    Feb 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default WCHAR and CHAR

    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...
    So if there is no compiler option in QT what is the clean way to convert WCHAR to char and vice vesa?

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: WCHAR and CHAR

    The way Visual studio handles unicode is flawed. Use QStrings instead. Have a look at the following static member functions:
    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 )
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. QString to wchar
    By rajveer in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2008, 11:19
  2. wchar to T50 conversion
    By rajveer in forum General Programming
    Replies: 1
    Last Post: 29th August 2008, 13:32
  3. WCHAR to QString giving error in vs2005
    By ucomesdag in forum Qt Programming
    Replies: 2
    Last Post: 1st May 2008, 23:25
  4. MinGW: char to WCHAR
    By Darhuuk in forum General Programming
    Replies: 4
    Last Post: 25th March 2008, 23:21
  5. char to const char* with atof
    By mickey in forum General Programming
    Replies: 5
    Last Post: 29th February 2008, 04:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.