PDA

View Full Version : Reading non-ASCII lines from QTcpSocket via readLine()



joshtn
26th June 2008, 21:31
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

jacek
27th June 2008, 00:52
You can use QTextStream to change the encoding, but unfortunately it doesn't have the canReadLine() method.