Difference between newline '/n' and carriage return '/r'

Line feed '/n' and carriage return '/r'

, as the names suggest, line feed is to start a new line, and carriage return is to return to the beginning of a line, so the carriage return we usually write files should be exactly called carriage return and line feed Symbol '/n' 10 newline

(newline)
'/r' 13 carriage return (return)


can also be expressed as '/x0a' and '/x0d'

. /r/n". But there is no "/r" symbol under Linux and other systems.

When parsing the content of files in text or other formats, it is often necessary to judge the carriage return and line feed. At this time, it is necessary to pay attention to judge both "/r/n" and "/n".

When writing a program, you may get a line, trim it with '/r', so you can get the string you need.



After knowing this problem, Sanxian added the /r character to the original code that removed the /n newline, and then tried to run the program, and finally restored the normal data format.


Summary: Invisible characters like /r/n can be judged and removed at the end when the program writes to the file, so as not to send

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325076131&siteId=291194637