开发者

Difference between \015 & \012 and \r & \n

I have an old C++ program that is writing files and FTPing them to a IBM mainframe.

This program is being converted to C#.

Things seems OK in transferring but the mainframe viewer is not displaying the file properly.

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

Could this be why things don't appear properly?

The files are getting transferred as ASCII so unsure why it开发者_如何学C appears like garbage!


\015 is an octal literal, which C# does not support.
C# parses it as \0 (character code zero) followed by the two characters 15


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

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

Octal is base 8, and when converted to base 10, 015 equates to 13, and 012 equates to 10. I hope that clears things up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜