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>()
);
}Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
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.