comparison mercurial/encoding.py @ 37883:443029011990 stable

encoding: alias cp65001 to utf-8 on Windows As far as I can tell, cp65001 is the Windows name for UTF-8. I don't know how different it is from the UTF-8, but Python 3 appears to have introduced new codec for cp65001, so the alias is enabled only for Python 2. https://bugs.python.org/issue13216 This patch is untested, but hopefully fixes the following issue. https://bitbucket.org/tortoisehg/thg/issues/5127/
author Yuya Nishihara <yuya@tcha.org>
date Sun, 01 Jul 2018 23:36:53 +0900
parents d4c760c997cd
children 7acec9408e1c
comparison
equal deleted inserted replaced
37882:3a0f322af192 37883:443029011990
70 70
71 _encodingfixers = { 71 _encodingfixers = {
72 '646': lambda: 'ascii', 72 '646': lambda: 'ascii',
73 'ANSI_X3.4-1968': lambda: 'ascii', 73 'ANSI_X3.4-1968': lambda: 'ascii',
74 } 74 }
75 # cp65001 is a Windows variant of utf-8, which isn't supported on Python 2.
76 # No idea if it should be rewritten to the canonical name 'utf-8' on Python 3.
77 # https://bugs.python.org/issue13216
78 if pycompat.iswindows and not pycompat.ispy3:
79 _encodingfixers['cp65001'] = lambda: 'utf-8'
75 80
76 try: 81 try:
77 encoding = environ.get("HGENCODING") 82 encoding = environ.get("HGENCODING")
78 if not encoding: 83 if not encoding:
79 encoding = locale.getpreferredencoding().encode('ascii') or 'ascii' 84 encoding = locale.getpreferredencoding().encode('ascii') or 'ascii'