Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize a text file and replace \r\n on Windows to \n #123

Open
sergey-shandar opened this issue Oct 28, 2023 · 0 comments
Open

Recognize a text file and replace \r\n on Windows to \n #123

sergey-shandar opened this issue Oct 28, 2023 · 0 comments

Comments

@sergey-shandar
Copy link
Contributor

sergey-shandar commented Oct 28, 2023

This applies only to Windows:

Methods:

  1. file extension. This is more error-prone.
  2. UTF-8 compatibility.

add command

The command can scan a file to see if it's UTF-8 compatible. It's more important than the get command. Options:

  1. during add, the program scans a file to see if it's a UTF-8 file. If yes, then it will add with conversion.
  2. a command that will convert all UTF-8 files into UNIX format.

Note: Using # 1, be cautious about sequences like this: \r\r\n. We shouldn't convert it to \r\n because during the get command we will not revert it back to \r\r\n.

get command

During get we can set a flag if the file is UTF-8. Also, we calculate how many new lines \n in the file w/o \r. If yes, we convert a temporary file to Windows format, and after that, we copy the file. We are converting the file by extending it from the back by a number of \n.

@sergey-shandar sergey-shandar changed the title Recognize text file and replace \r\n on Windows Recognize text file and replace \r\n on Windows to \n Oct 28, 2023
@sergey-shandar sergey-shandar changed the title Recognize text file and replace \r\n on Windows to \n Recognize a text file and replace \r\n on Windows to \n Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant