The difference between \ 015 & \ 012 and \ r & \ n

I have an old C ++ program that writes files and transfers them to the IBM mainframe.

This program is converted to C #.

Everything seems to be in order, but the mainframe viewer is not displaying the file properly.

What is the difference between \015 and \012 and \r and \n ? C ++ uses numbers, and C # uses \r\n .

Maybe that's why things are not displayed properly?

Files are transferred as ASCII, so they are not sure why they look like garbage!

+6
c ++ c # encoding
source share
2 answers

\015 is an octal literal that C # does not support. C # parses it as \0 (null character of a character) followed by two characters 15

+7
source share

There is no difference between \r\n and \015\012 .

In C (++), the escape sequence \0XX stands for the literal octal representation of char. If you print these values ​​as numbers, you should see that \r matches 13 and \n matches 10 .

The octal is base 8, and when converted to base 10 015 corresponds to 13 , and 012 corresponds to 10 . I hope this clarifies the situation.

+6
source share

All Articles