import unicodedataimport sys# HFS Plus uses decomposed UTF-8def decompose(path):if isinstance(path, str):return unicodedata.normalize('NFD', path)try:path = path.decode('utf-8')path = unicodedata.normalize('NFD', path)path = path.encode('utf-8')except UnicodeError:pass # Not UTF-8return pathdef filesys_decode(path):"""Ensure that the given path is decoded,NONE when no expected encoding works"""if isinstance(path, str):return pathfs_enc = sys.getfilesystemencoding() or 'utf-8'candidates = fs_enc, 'utf-8'for enc in candidates:try:return path.decode(enc)except UnicodeDecodeError:continuedef try_encode(string, enc):"turn unicode encoding into a functional routine"try:return string.encode(enc)except UnicodeEncodeError:return None
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。