Results 1 to 6 of 6

Thread: How to Compare Characters ASCII value?

  1. #1
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Question How to Compare Characters ASCII value?

    Hi all

    working on Qt4.3, I want to know how to compare Character Ascii values .

    For eg.

    QString str;

    how can i get that, Is str contains Character Ascii values between [0-31], if str contains the value between [0-31], then also how can i remove that ASCII value lies between [0-31].
    Always Believe in Urself
    Merry

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to Compare Characters ASCII value?

    use toAscii to get 8-bit ASCII representation of the string

  3. #3
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to Compare Characters ASCII value?

    Thanks 4 d reply, It returns an 8-bit ASCII representation of the string,
    but how can i compare this , that the ASCII values is between [0-31] or not.

    Pls explain it with me example
    Always Believe in Urself
    Merry

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry Re: How to Compare Characters ASCII value?

    You may very well write ur own function for that -

    Qt Code:
    1. void removeDirtyChars(QString &input)
    2. {
    3. QByteArray asciiInput = input.toAscii();
    4. input.clear();
    5. for(int i=0;i<asciiInput.length();i++)
    6. {
    7. if(asciiInput.at(i) is not between [0-31] // You logic to determine which chars u want
    8. input += asciiInput.at(i);
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 
    Hope u get the logic
    Last edited by jpn; 27th July 2008 at 08:49. Reason: missing [code] tags

  5. The following user says thank you to aamer4yu for this useful post:

    merry (14th July 2008)

  6. #5
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to Compare Characters ASCII value?

    Thanks for d reply, I got the logic, but there is a confusion in a line

    Qt Code:
    1. if(asciiInput.at(i) is not between [0-31] You logic to determine which chars u want
    To copy to clipboard, switch view to plain text mode 

    I want to compare all the characters whose ASCII value lies between [0-31], how can i do this, Is I have to compare ASCII value one by one or is there any other logic
    Always Believe in Urself
    Merry

  7. #6
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to Compare Characters ASCII value?

    Thanks all my problem is solved.
    Always Believe in Urself
    Merry

Similar Threads

  1. Replies: 4
    Last Post: 10th July 2007, 20:11
  2. Problem at time compilation in traslation of language
    By thomasjoy in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2007, 14:18

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.