Reading strings containing escape sequence.
-
Hi, In my application, I need to read an unicode string _T("AT+COPS=?\r") from an xml file. The problem I am facing is that when I read an string from the xml file, it is treating the elements "\r" in "AT+COPS=?\r" as 2 different characters rather than a single carriage return value. How do I get around this problem.
-
Hi, In my application, I need to read an unicode string _T("AT+COPS=?\r") from an xml file. The problem I am facing is that when I read an string from the xml file, it is treating the elements "\r" in "AT+COPS=?\r" as 2 different characters rather than a single carriage return value. How do I get around this problem.
That's how it is supposed to work. Escape sequences are only used this way in string litterals (e.g., when you write the string yourself in the code). If you read that from a file, "\r" are two characters and they are treated as two independant characters. What you have to understand about escape sequences (like "\r") is that they are replaced by your compiler by a single character. If you really want to do something like you that, you will need to parse the string yourself and replace the sequence yourself.
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++