Project

General

Profile

Actions

Bug #13372

closed

File class is not able to identify EOL for file text using CR character .

Added by saul.rosales.b (Saul Rosales) about 7 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:80416]

Description

Hello I am Ruby developer for qualcomm company we were creating a upload feature that is gathering text files for source code or configuraiton files from whatever platform they are written, as Windows, Mac OS all versions, Linux all versions. and I found that I needed to normalize the files that comes from different OS vendors, for files using CR as EOL character, File class was not able to identify that character as EOL, there is a method for reading line by line but it is usless in that case.

Could you please let me know if I can contribute to fix it? How can I get involved in helping the Ruby community?

Regards

Saul Rosales

Updated by shyouhei (Shyouhei Urabe) about 7 years ago

Hello.

saul.rosales.b (Saul Rosales) wrote:

Hello I am Ruby developer for qualcomm company we were creating a upload feature that is gathering text files for source code or configuraiton files from whatever platform they are written, as Windows, Mac OS all versions, Linux all versions. and I found that I needed to normalize the files that comes from different OS vendors, for files using CR as EOL character, File class was not able to identify that character as EOL, there is a method for reading line by line but it is usless in that case.

There are several ways (I think) to tell what character terminates a line. For instance, you can specify "universal newline" mode to the open flag like:

File.open("path/to/file", "rt") # <- "r" for read, "t" for the newline conversion

Depending on what operation you do over the files, there might be a better way. If the above mode specifier does not fit well, please show us your use case. Small code snippet that describes your problem is the best. Thank you.

Actions #2

Updated by nobu (Nobuyoshi Nakada) about 7 years ago

  • Status changed from Open to Feedback
Actions #3

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Feedback to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0