]> crepu.dev Git - config.git/blame - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/setuptools/unicode_utils.py
Archivo de configuraciĆ³n de la terminal
[config.git] / djavu-asus / elpy / rpc-venv / lib / python3.11 / site-packages / setuptools / unicode_utils.py
CommitLineData
53e6db90
DC
1import unicodedata
2import sys
3
4
5# HFS Plus uses decomposed UTF-8
6def decompose(path):
7 if isinstance(path, str):
8 return unicodedata.normalize('NFD', path)
9 try:
10 path = path.decode('utf-8')
11 path = unicodedata.normalize('NFD', path)
12 path = path.encode('utf-8')
13 except UnicodeError:
14 pass # Not UTF-8
15 return path
16
17
18def filesys_decode(path):
19 """
20 Ensure that the given path is decoded,
21 NONE when no expected encoding works
22 """
23
24 if isinstance(path, str):
25 return path
26
27 fs_enc = sys.getfilesystemencoding() or 'utf-8'
28 candidates = fs_enc, 'utf-8'
29
30 for enc in candidates:
31 try:
32 return path.decode(enc)
33 except UnicodeDecodeError:
34 continue
35
36
37def try_encode(string, enc):
38 "turn unicode encoding into a functional routine"
39 try:
40 return string.encode(enc)
41 except UnicodeEncodeError:
42 return None