rust-newline-converter-cli

Crates.iorust-newline-converter-cli
lib.rsrust-newline-converter-cli
version0.1.2
sourcesrc
created_at2020-06-07 09:15:17.839706
updated_at2022-11-09 11:59:59.823179
descriptionNewline byte converter library
homepage
repositoryhttps://github.com/spitfire05/rnc
max_upload_size
id250912
size34,824
MichaƂ Borejszo (spitfire05)

documentation

README

Rust Newline Converter (rnc)

A "dos2unix lookalike" written in Rust

Build Status Crates.io

The motivation to write this crate had two main pivot points:

  • My "learning Rust" project
  • dos2unix being either not available or bugged on some weird platforms, like Android shell

However, similarities to dos2unix are in functionality only, the CLI interface was not designed to be similar to the one of dos2unix in any way.

Tool usage

rnc 0.1
Newline byte(s) converter

USAGE:
    rnc.exe [FLAGS] [OPTIONS] --dos2unix --unix2dos [FILE]...

FLAGS:
    -f, --force       Don't omit binary files
    -d, --debug       Print out debug info
        --dos2unix    Convert DOS line endings to Unix (\r\n -> \n)
    -h, --help        Prints help information
        --unix2dos    Convert Unix line endings to DOS (\n -> \r\n)
    -V, --version     Prints version information
    -v, --verbose     Be verbose about the operations

OPTIONS:
    -e, --encode <ENCODE>    Encode output in given encoding [possible values: utf8, utf16, utf16be]
    -o, --output <OUT>       Write to OUT instead of FILE or stdout. Can only be used if FILE is specified just once

ARGS:
    <FILE>...    Sets the input file to use. If not set, processes stdin to stdout

Conversion caveats

rnc respects the valid newline character(s) of the input file. That means, if you use --unix2dos and there's a lone \r in the input buffer, it will not be converted to \r\n, as it is not valid newline sequence.

In future there might be an option to override this behavior.

Performance

One of the main developement goals, was to achieve conversion times not worse that the ones of dos2unix. On Linux host, the performance is roughly similar (about 0.1s difference when converting ~100MB file), while on windows rnc is twice as fast as dos2unix (version downloaded from https://sourceforge.net/projects/dos2unix/).

MSRV

Minimum Supported Rust Version is 1.40.0.

Commit count: 98

cargo fmt