简体   繁体   English

如果 EOL 字符是 LF,如何读取文件

[英]how to read a file if EOL char is LF

I receive a file from internet, and the lines are separated by 0x0D char I display it using this tool我从 Internet 收到一个文件,各行以 0x0D 字符分隔 我使用此工具显示它

https://www.fileformat.info/tool/hexdump.htm https://www.fileformat.info/tool/hexdump.htm

When I read that file into Rexx using "linein()", all the file comes into one sigle line.当我使用“linein()”将该文件读入 Rexx 时,所有文件都变成了一行。 Obviously linein() works fine when file has 0x0D0A as End Of Line char.显然,当文件将 0x0D0A 作为行尾字符时,linein() 工作正常。

How do I specify to Rexx to split lines using 0x0D char instead of 0x0D0A ?如何指定 Rexx 使用 0x0D 字符而不是 0x0D0A 来分割线?

Apart from getting the file sent to you with proper CRLF record markers for Windows instead of the LF used in Unix-like systems there are a couple of ways of splitting the data - but neither will read the file a record at a time but will extract each record from the long string read in. 1 - Use WORDPOS to find the position of the LF and SUBSTR to remove that the record 2 - Use PARSE to split the data at the LF position除了使用适用于 Windows 的适当 CRLF 记录标记而不是类 Unix 系统中使用的 LF 将文件发送给您之外,还有几种拆分数据的方法 - 但它们都不会一次读取文件记录但会提取读入长字符串中的每条记录。 1 - 使用 WORDPOS 查找 LF 的位置,使用 SUBSTR 删除该记录 2 - 使用 PARSE 在 LF 位置拆分数据

One way to read one record at a time is to use CHARIN to read a byte at a time until it encounters the LF.一次读取一条记录的一种方法是使用 CHARIN 一次读取一个字节,直到遇到 LF。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM