comparison mercurial/encoding.py @ 15142:176882876780

encoding: colwidth input is in the local encoding
author Matt Mackall <mpm@selenic.com>
date Wed, 21 Sep 2011 13:00:41 -0500
parents 24efa83d81cb
children 16c129b0f465
comparison
equal deleted inserted replaced
15141:16dc9a32ca04 15142:176882876780
137 # How to treat ambiguous-width characters. Set to 'wide' to treat as wide. 137 # How to treat ambiguous-width characters. Set to 'wide' to treat as wide.
138 wide = (os.environ.get("HGENCODINGAMBIGUOUS", "narrow") == "wide" 138 wide = (os.environ.get("HGENCODINGAMBIGUOUS", "narrow") == "wide"
139 and "WFA" or "WF") 139 and "WFA" or "WF")
140 140
141 def colwidth(s): 141 def colwidth(s):
142 "Find the column width of a UTF-8 string for display" 142 "Find the column width of a string for display in the local encoding"
143 return ucolwidth(s.decode(encoding, 'replace')) 143 return ucolwidth(s.decode(encoding, 'replace'))
144 144
145 def ucolwidth(d): 145 def ucolwidth(d):
146 "Find the column width of a Unicode string for display" 146 "Find the column width of a Unicode string for display"
147 eaw = getattr(unicodedata, 'east_asian_width', None) 147 eaw = getattr(unicodedata, 'east_asian_width', None)