Comments
Patch
@@ -93,7 +93,7 @@
try:
encoding = environ.get("HGENCODING")
if not encoding:
- encoding = locale.getpreferredencoding() or 'ascii'
+ encoding = locale.getpreferredencoding(False) or 'ascii'
encoding = _encodingfixers.get(encoding, lambda: encoding)()
except locale.Error:
encoding = 'ascii'
@@ -146,11 +146,14 @@
try:
try:
+ if encoding == 'UTF-8':
+ # fast path
+ if isinstance(s, unicode):
+ return s
+ else:
+ return s.decode('UTF-8')
# make sure string is actually stored in UTF-8
u = s.decode('UTF-8')
- if encoding == 'UTF-8':
- # fast path
- return s
r = u.encode(_sysstr(encoding), u"replace")
if u == r.decode(_sysstr(encoding)):
# r is a safe, non-lossy encoding of s