-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Remove \r\n for \n when writing to ostream #24980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Why? Is there an issue for this? |
|
@BrennanConroy do you remember if there was an issue for this? IIRC there was one filed in the past. We have noticed it multiple times when debugging stdout logs from customers and other things. |
|
I know I complained about it in the past, there may have been an issue at one point from an external customer... |
| const auto multiByte = to_multi_byte_string(text, CP_UTF8); | ||
| auto multiByte = to_multi_byte_string(text, CP_UTF8); | ||
|
|
||
| // Writing \r\n to an ostream will cause two new lines to be written rather |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will \n will be written without \r in the final file output?
Also, I don't think ostream was the issue, iirc it was a Windows API we were calling the duplicated the newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, when I was testing it, I called ostream << "test\r\n" and I see two new lines in the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this ostream the fake file that is then redirected? I could be wrong, it has been a long time since I looked at this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe so, the m_file points directly to the stdout file.
|
|
||
| Assert.Contains("TEST MESSAGE", contents); | ||
| Assert.DoesNotContain("\r\n\r\n", contents); | ||
| Assert.Contains("\r\n", contents); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
When writing to the stdout file with ANCM, for some reason, \r\n get interpreted as two new lines when writing to an ostream. This change replaces \r\n with \n before writing to the file.