Results 1 to 4 of 4

Thread: how to detect Ñ or alt+165 from Qstring?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default how to detect Ñ or alt+165 from Qstring?

    hi,

    im having a bit of trouble in detecting Ñ or alt+165 in a string..

    im using str.indexOf("Ñ") but it detects different char..

    how to this properly please help..

    tnx

  2. #2
    Join Date
    Jul 2008
    Location
    Spain
    Posts
    23
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to detect Ñ or alt+165 from Qstring?

    I am using Qt4.4 in Kubuntu 8.04 with UTF-8 encoding as default.

    This applicacion writen in a UTF-8 text file works for me.

    Try it, I hope it can helps you.

    Qt Code:
    1. #include <QString>
    2. #include <TextStream>
    3.  
    4.  
    5. int main()
    6. {
    7. QTextStream salida(stdout);
    8. QString cadena;
    9.  
    10. cadena = "aquÃ* Ñ está";
    11.  
    12. salida<<cadena.indexOf("Ñ")<<endl;
    13. }
    To copy to clipboard, switch view to plain text mode 
    Auryn
    Starting to learn the world of Qt

  3. #3
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to detect Ñ or alt+165 from Qstring?

    Quote Originally Posted by Auryn View Post
    I am using Qt4.4 in Kubuntu 8.04 with UTF-8 encoding as default.
    This applicacion writen in a UTF-8 text file works for me.
    the code you wrote is what exactly what im doing.. but its changing the Ñ to some other characters.. how to change the encoding? so that it will not convert the Ñ to other chars?

  4. #4
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to detect Ñ or alt+165 from Qstring?

    atlast.. my problem solve by using

    str.indexOf(QString::fromUtf8("Ñ"))

    atleast i got the idea of utf-8 tnx

Similar Threads

  1. easiest Way QString can do
    By baray98 in forum Qt Programming
    Replies: 12
    Last Post: 15th April 2008, 20:49
  2. QString static callback function from CURL
    By tpf80 in forum Qt Programming
    Replies: 12
    Last Post: 16th May 2007, 20:47
  3. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  4. Converting QString to unsigned char
    By salston in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 22:10
  5. [SOLVED] Widget plugin ... how to ?
    By yellowmat in forum Newbie
    Replies: 10
    Last Post: 29th January 2006, 20:41

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
  •  
Qt is a trademark of The Qt Company.