Skip to content

Instantly share code, notes, and snippets.

@pjdietz
Created August 4, 2013 15:41
Show Gist options
  • Save pjdietz/6150742 to your computer and use it in GitHub Desktop.
Save pjdietz/6150742 to your computer and use it in GitHub Desktop.
Normalize Line Endings
def normalize_line_endings(string, eol):
"""Return a string with consistent line endings."""
string = string.replace("\r\n", "\n").replace("\r", "\n")
if eol != "\n":
string = string.replace("\n", eol)
return string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment