Results 1 to 2 of 2

Thread: toAscii() in Qt5

  1. #1
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default toAscii() in Qt5

    I am looking for a suitable replacement of toAscii(), since it is deprecated in Qt5.

    Is
    Qt Code:
    1. QString str("test");
    2. const char* ptr = (const char*) (str.utf16());
    To copy to clipboard, switch view to plain text mode 

    a good substitute for toAscii()?

    Advise/comment is appreciated, thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,355
    Thanks
    3
    Thanked 5,010 Times in 4,789 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: toAscii() in Qt5

    Quote Originally Posted by TorAn View Post
    I am looking for a suitable replacement of toAscii(),
    toLatin1(), as the docs say.

    Is
    Qt Code:
    1. QString str("test");
    2. const char* ptr = (const char*) (str.utf16());
    To copy to clipboard, switch view to plain text mode 

    a good substitute for toAscii()?
    No, this is wrong. utf16() gives you utf-16 representation (not very hard to guess that) while toAscii() returns 8-bit representation.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    zeFree (26th February 2017)

Similar Threads

  1. Replies: 2
    Last Post: 3rd March 2010, 11:08

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.