nasg/.venv/lib/python3.6/site-packages/frontmatter/util.py
2018-07-25 13:23:23 +01:00

15 lines
No EOL
335 B
Python

# -*- coding: utf-8 -*-
"""
Utilities for handling unicode and other repetitive bits
"""
import six
def u(text, encoding='utf-8'):
"Return unicode text, no matter what"
if isinstance(text, six.binary_type):
text = text.decode(encoding)
# it's already unicode
text = text.replace('\r\n', '\n')
return text