[MERGE] Make annotate behave in a non-ASCII world
Adeodato Simó
dato at net.com.org.es
Fri Jul 6 18:52:25 BST 2007
* Aaron Bentley [Fri, 06 Jul 2007 13:37:39 -0400]:
> Adeodato Simó wrote:
> > I think this, or some other solution, is a must have, even if everybody
> > prefers gannotate these days. ;-)
> > + try:
> > + to_file.write(anno)
> > + except UnicodeEncodeError:
> > + to_file.write(anno.encode(to_file.encoding, 'replace'))
> Could you say why you're trying and catching the exception here? I
> think it would be better to encode the string unconditionally.
Because we want the 'replace' encoding to happen *only* if the to_file
object can't handle the characters in anno (which happens if for example
a user with LANG=C annotates a file where one commiter had non-ascii
characters).
Unconditionally encoding is not desirable (as John also pointed out to
me the first time) because users with the appropriate $LANG would see an
unnecessarily mutilated string (which in the case of non-latin scripts
would be the whole string).
Hope the explanation was clear.
--
Adeodato Simó dato at net.com.org.es
Debian Developer adeodato at debian.org
Algebraic symbols are used when you do not know what you are talking about.
-- Philippe Schnoebelen
More information about the bazaar
mailing list