Path: blob/master/venv/Lib/site-packages/setuptools/unicode_utils.py
811 views
import unicodedata1import sys23from setuptools.extern import six456# HFS Plus uses decomposed UTF-87def decompose(path):8if isinstance(path, six.text_type):9return unicodedata.normalize('NFD', path)10try:11path = path.decode('utf-8')12path = unicodedata.normalize('NFD', path)13path = path.encode('utf-8')14except UnicodeError:15pass # Not UTF-816return path171819def filesys_decode(path):20"""21Ensure that the given path is decoded,22NONE when no expected encoding works23"""2425if isinstance(path, six.text_type):26return path2728fs_enc = sys.getfilesystemencoding() or 'utf-8'29candidates = fs_enc, 'utf-8'3031for enc in candidates:32try:33return path.decode(enc)34except UnicodeDecodeError:35continue363738def try_encode(string, enc):39"turn unicode encoding into a functional routine"40try:41return string.encode(enc)42except UnicodeEncodeError:43return None444546