Skip to content

About

Line endings normalizer

Topics

Resources

Code of conduct

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

normalized-line-endings

crates.io build coverage mbh

Line endings normalizer

This crate provides an iterator over characters with normalized line endings, meaning all valid line endings in the input are converted to a single newline character: \n (U+000A), like this:

  • \n → \n
  • \r → \n
  • \r\n → \n

The normalized iterator can be created by calling the method normalized on any iterator over characters, like in this example:

use normalized_line_endings::Normalized;

fn main() {
  let input = "Lorem \n ipsum \r dolor \n\r\n sit \r\r\n\n amet";
  assert_eq!(
    "Lorem \n ipsum \n dolor \n\n sit \n\n\n amet",
    input.chars().normalized().collect::<String>()
  );
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Line endings normalizer

Topics

Resources

Code of conduct

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages