Results 1 to 2 of 2

Thread: Reading non-ASCII lines from QTcpSocket via readLine()

  1. #1
    Join Date
    Jun 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Reading non-ASCII lines from QTcpSocket via readLine()

    Hello.

    I have an application that communicates via TCP connection. I see that QTcpSocket has a canReadLine() function that checks the stream for an ASCII newline character. This works fine if the strings you are passing back and forth are in ASCII.

    My question is, can you change the encoding it's using? My application will be writing UTF-8 strings and canReadLine() might interpret a '\n' byte in a Unicode character as a newline.

    Is there a simple way to do this? Can someone post some example code on how to do this?

    Thanks,
    --josh

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Reading non-ASCII lines from QTcpSocket via readLine()

    You can use QTextStream to change the encoding, but unfortunately it doesn't have the canReadLine() method.

Similar Threads

  1. QWT 5, QT3, SuSE 10.2. Crash and burn
    By DrMcCleod in forum Qwt
    Replies: 8
    Last Post: 7th September 2007, 20:53

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.