带有 0D 0D 0A 换行符的文本文件 [英] Text file with 0D 0D 0A line breaks

查看:23
本文介绍了带有 0D 0D 0A 换行符的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一位客户向我发送了一个 .csv 文件,其中的换行符由序列 0xD 0xD 0xA 组成.据我所知,换行符是 Mac 或 Unix 的 0xA 或 Windows 的 0xD 0xA.

A customer is sending me a .csv file where the line breaks are made up of the sequence 0xD 0xD 0xA. As far as I know line breaks are either 0xA from Mac or Unix or 0xD 0xA from Windows.

0xD 0xD 0xA 是任何已知的编码吗?是否有任何已知的节省序列会破坏文件的行尾,从而导致这种情况(我认为客户使用的是 Mac)?

Is the 0xD 0xD 0xA any known encoding? Is there any known sequence of savings that corrupts a file's line endings that causes this (I think the customer uses a Mac)?

该文件不以任何编码标记开头,而是直接以文本内容开头.如果使用代码页 1252 打开,文本将正确显示.

The file doesn't start with any encoding markers, it starts with the text contents directly. The text is displayed correctly if opened with code page 1252.

推荐答案

CRCRLF 被称为 Windows XP 记事本自动换行错误.

The CRCRLF is known as result of a Windows XP notepad word wrap bug.

为了将来参考,以下是链接博客的相关摘录:

For future reference, here's an extract of relevance from the linked blog:

当您在 Windows 计算机上按 Enter 键时,实际上会存储两个字符:回车 (CR) 和换行 (LF).操作系统总是以与 Enter 键相同的方式解释字符序列 CR LF:它移动到下一行.但是,当它们本身有额外的 CR 或 LF 字符时,这有时会导致问题.

When you press the Enter key on Windows computers, two characters are actually stored: a carriage return (CR) and a line feed (LF). The operating system always interprets the character sequence CR LF the same way as the Enter key: it moves to the next line. However when there are extra CR or LF characters on their own, this can sometimes cause problems.

Windows XP 版本的记事本中存在一个错误,该错误会导致显示窗口中存储额外的 CR 字符.该错误发生在以下情况:

There is a bug in the Windows XP version of Notepad that can cause extra CR characters to be stored in the display window. The bug happens in the following situation:

如果您打开了自动换行选项并且显示窗口包含环绕的长行,则保存文件会导致记事本在显示窗口的每个换行点插入字符 CR CR LF,但不在保存的文件.

If you have the word wrap option turned on and the display window contains long lines that wrap around, then saving the file causes Notepad to insert the characters CR CR LF at each wrap point in the display window, but not in the saved file.

如果您将 CR CR LF 字符复制并粘贴到其他程序中,它们可能会导致异常.如果您调整记事本窗口的大小,它们还会阻止记事本正确地重新换行.

The CR CR LF characters can cause oddities if you copy and paste them into other programs. They also prevent Notepad from properly re-wrapping the lines if you resize the Notepad window.

您可以通过关闭自动换行功能来​​删除 CR CR LF 字符,然后根据需要将其重新打开.但是,执行此操作时,光标会重新定位在显示窗口的开头.

You can remove the CR CR LF characters by turning off the word wrap feature, then turning it back on if desired. However, the cursor is repositioned at the beginning of the display window when you do this.

这篇关于带有 0D 0D 0A 换行符的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆