Use platform neutral line separator(s)

To at least try to support things like windows it's better
if we can make an attempt to use the platform neutral
characters for line separator(s) where appropriate.

Change-Id: Icc533ed4d4c94f461b7f19600b74146221f17b18
This commit is contained in:
Joshua Harlow
2015-01-11 13:03:26 -08:00
committed by Joshua Harlow
parent ab71a2677d
commit 42a665d06f
10 changed files with 47 additions and 18 deletions

View File

@@ -142,6 +142,11 @@ def clamp(value, minimum, maximum, on_clamped=None):
return value
def fix_newlines(text, replacement=os.linesep):
"""Fixes text that *may* end with wrong nl by replacing with right nl."""
return replacement.join(text.splitlines())
def binary_encode(text, encoding='utf-8'):
"""Converts a string of into a binary type using given encoding.