Expand description

A library for newline character converting.

Examples

Using the extension trait:

use newline_converter::AsRefStrExt;
assert_eq!("foo\r\nbar", "foo\nbar".to_dos());
use newline_converter::AsRefStrExt;
assert_eq!("foo\nbar", "foo\r\nbar".to_unix());

Using conversion functions directly:

assert_eq!("foo\r\nbar", newline_converter::unix2dos("foo\nbar"));
assert_eq!("foo\nbar", newline_converter::dos2unix("foo\r\nbar"));

The conversion functions are lazy - they don’t perform any allocations if the input is already in correct format.

Traits

  • Extension trait for converting between DOS and UNIX linebreaks.

Functions

  • Converts DOS-style line endings (\r\n) to UNIX-style (\n).
  • Converts UNIX-style line endings (\n) to DOS-style (\r\n).