Skip to content

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

@sergey-shandar

Description

@sergey-shandar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions