scan text for escape characters
Hi,
I need to change escape characters in my text document (for example change every \r to \n). What is the best way to do that using Qt and C++? I don't want to make any assumptions about the format (Win or Mac) while reading in the data.
I typically use QTextStream and readLine() to read text into QString and then I use replace() to make changes. Here I have two problems:
1. readLine loses newline characters (line breaks) - main problem
2. My entire document may be too large to fit in a QString - small problem
Are there any tricks to replacing escape characters compared to replacing simple letters or numbers?
Thanks!
Re: scan text for escape characters
Let's be clear here, you want to the replace the single carriage return character or the single line feed character, not the two character escapes you would see in C++ code.
Quote:
Are there any tricks to replacing escape characters compared to replacing simple letters or numbers?
No. Open file (QFile), read bytes (QIODevice::read()), replace characters (QByteArray::replace()), write bytes (QIODevice::write()).
Re: scan text for escape characters
Thank you, ChrisW67.
Problem solved.