unify_newlines

Function unify_newlines 

Source
pub fn unify_newlines(str: impl AsRef<str>) -> String
Expand description

Converts all types of newline sequences (\r, \n, \r\n) in a string to a single newline character (\n).

This is useful for normalizing text input that might come from different operating systems or sources with inconsistent line endings.

ยงExamples

let text = "Hello\r\nWorld\nAnother\rLine";
let unified = unify_newlines(text);
assert_eq!(unified, "Hello\nWorld\nAnother\nLine");