##// END OF EJS Templates
encoding: default ambiguous character to narrow...
Matt Mackall -
r12866:eddc2030 stable
parent child Browse files
Show More
@@ -87,11 +87,17 b' def fromlocal(s):'
87 except LookupError, k:
87 except LookupError, k:
88 raise error.Abort("%s, please check your locale settings" % k)
88 raise error.Abort("%s, please check your locale settings" % k)
89
89
90 # How to treat ambiguous-width characters. Set to 'wide' to treat as wide.
91 ambiguous = os.environ.get("HGENCODINGAMBIGUOUS", "narrow")
92
90 def colwidth(s):
93 def colwidth(s):
91 "Find the column width of a UTF-8 string for display"
94 "Find the column width of a UTF-8 string for display"
92 d = s.decode(encoding, 'replace')
95 d = s.decode(encoding, 'replace')
93 if hasattr(unicodedata, 'east_asian_width'):
96 if hasattr(unicodedata, 'east_asian_width'):
97 wide = "WF"
98 if ambiguous == "wide":
99 wide = "WFA"
94 w = unicodedata.east_asian_width
100 w = unicodedata.east_asian_width
95 return sum([w(c) in 'WFA' and 2 or 1 for c in d])
101 return sum([w(c) in wide and 2 or 1 for c in d])
96 return len(d)
102 return len(d)
97
103
@@ -24,6 +24,13 b' HGENCODINGMODE'
24 "ignore", which drops them. This setting can be overridden with
24 "ignore", which drops them. This setting can be overridden with
25 the --encodingmode command-line option.
25 the --encodingmode command-line option.
26
26
27 HGENCODINGAMBIGUOUS
28 This sets Mercurial's behavior for handling characters with
29 "ambiguous" widths like accented Latin characters with East Asian
30 fonts. By default, Mercurial assumes ambiguous characters are
31 narrow, set this variable to "wide" if such characters cause
32 formatting problems.
33
27 HGMERGE
34 HGMERGE
28 An executable to use for resolving merge conflicts. The program
35 An executable to use for resolving merge conflicts. The program
29 will be executed with three arguments: local file, remote file,
36 will be executed with three arguments: local file, remote file,
@@ -166,13 +166,13 b' hg tags (latin-1)'
166
166
167 $ HGENCODING=latin-1 hg tags
167 $ HGENCODING=latin-1 hg tags
168 tip 5:093c6077d1c8
168 tip 5:093c6077d1c8
169 3:ca661e7520de
169 3:ca661e7520de
170
170
171 hg tags (utf-8)
171 hg tags (utf-8)
172
172
173 $ HGENCODING=utf-8 hg tags
173 $ HGENCODING=utf-8 hg tags
174 tip 5:093c6077d1c8
174 tip 5:093c6077d1c8
175 é 3:ca661e7520de
175 é 3:ca661e7520de
176
176
177 hg branches (ascii)
177 hg branches (ascii)
178
178
@@ -183,13 +183,13 b' hg branches (ascii)'
183 hg branches (latin-1)
183 hg branches (latin-1)
184
184
185 $ HGENCODING=latin-1 hg branches
185 $ HGENCODING=latin-1 hg branches
186 5:093c6077d1c8
186 5:093c6077d1c8
187 default 4:94db611b4196 (inactive)
187 default 4:94db611b4196 (inactive)
188
188
189 hg branches (utf-8)
189 hg branches (utf-8)
190
190
191 $ HGENCODING=utf-8 hg branches
191 $ HGENCODING=utf-8 hg branches
192 é 5:093c6077d1c8
192 é 5:093c6077d1c8
193 default 4:94db611b4196 (inactive)
193 default 4:94db611b4196 (inactive)
194 $ echo '[ui]' >> .hg/hgrc
194 $ echo '[ui]' >> .hg/hgrc
195 $ echo 'fallbackencoding = koi8-r' >> .hg/hgrc
195 $ echo 'fallbackencoding = koi8-r' >> .hg/hgrc
General Comments 0
You need to be logged in to leave comments. Login now