equal
deleted
inserted
replaced
24 import re |
24 import re |
25 |
25 |
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 |
32 def section(s): |
33 def section(s): |
33 return "%s\n%s\n\n" % (s, "\"" * encoding.colwidth(s)) |
34 return "%s\n%s\n\n" % (s, "\"" * encoding.colwidth(s)) |
57 |
58 |
58 # some character encodings (cp932 for Japanese, at least) use |
59 # some character encodings (cp932 for Japanese, at least) use |
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 |
69 def findblocks(text): |
70 def findblocks(text): |
70 """Find continuous blocks of lines in text. |
71 """Find continuous blocks of lines in text. |