Skip to main content

normalize_line_endings_for_diff

Function normalize_line_endings_for_diff 

Source
pub fn normalize_line_endings_for_diff(content: &str) -> String
Expand description

Normalize line endings to LF (FR-FIX-010, FR-FS-004, FR-FS-005)

This function converts all line ending styles (CRLF, CR, LF) to LF. This ensures consistent diff calculation regardless of the source file’s line ending style, which is especially important on Windows where files may have CRLF line endings.

§Arguments

  • content - The content to normalize

§Returns

A string with all line endings normalized to LF (\n)

§Examples

use xchecker_engine::fixup::normalize_line_endings_for_diff;

let crlf_content = "line1\r\nline2\r\n";
let normalized = normalize_line_endings_for_diff(crlf_content);
assert_eq!(normalized, "line1\nline2\n");