##// END OF EJS Templates
minirst: make encoding.encoding unicodes to pass into encode() and decode()
Pulkit Goyal -
r31318:1c3352d7 default
parent child Browse files
Show More
@@ -26,6 +26,7 b' import re'
26 from .i18n import _
26 from .i18n import _
27 from . import (
27 from . import (
28 encoding,
28 encoding,
29 pycompat,
29 util,
30 util,
30 )
31 )
31
32
@@ -59,10 +60,10 b' def replace(text, substs):'
59 # ASCII characters other than control/alphabet/digit as a part of
60 # ASCII characters other than control/alphabet/digit as a part of
60 # multi-bytes characters, so direct replacing with such characters
61 # multi-bytes characters, so direct replacing with such characters
61 # on strings in local encoding causes invalid byte sequences.
62 # on strings in local encoding causes invalid byte sequences.
62 utext = text.decode(encoding.encoding)
63 utext = text.decode(pycompat.sysstr(encoding.encoding))
63 for f, t in substs:
64 for f, t in substs:
64 utext = utext.replace(f.decode("ascii"), t.decode("ascii"))
65 utext = utext.replace(f.decode("ascii"), t.decode("ascii"))
65 return utext.encode(encoding.encoding)
66 return utext.encode(pycompat.sysstr(encoding.encoding))
66
67
67 _blockre = re.compile(br"\n(?:\s*\n)+")
68 _blockre = re.compile(br"\n(?:\s*\n)+")
68
69
General Comments 0
You need to be logged in to leave comments. Login now