[MERGE] Nicer location display in info

John Arbash Meinel john at arbash-meinel.com
Sat Jul 7 04:33:36 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aaron Bentley wrote:
> Aaron Bentley wrote:
>> John Arbash Meinel wrote:
>>> Aaron Bentley wrote:
>>> It would be nice if we could give 'LocationList' an self.outf.encoding, so that
>>> people who have non-ascii branches can see nicely formatted Unicode named
>>> locations.
>> Makes sense.
> 
> Actually, doesn't really make sense.  unescape_for_display is really
> counterintuitive.  I expected it to return an encoded string.  Anyone
> know why it doesn't?
> 
> Aaron

unescape_for_display returns a string that is ready to be sent to a Codec wrapper.

The problem is that if it is an encoded string (utf-8) then the codec wrapper
will *decode* it using the default string encoding (ascii) ==> broken.

Basically, a codec wrapper has a:

self.write(unicode(s).encode(self.my_encoding))

So all strings that pass into it *will* become unicode at some point. There is
no safe way to pass 8-bit strings to a StreamWrapper (or whatever the specific
name is). So I do the work to figure out what chunks I can unescape from URL
encoding, and then pass that back as a Unicode string.

Ugly? Yes. Does it do the thing that works. Yes. Would passing back an 8-bit
string fail. Yes.

I'm sorry it has to be that way.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGjwmQJdeBCYSNAAMRAoUbAJkBDzHuZPCyywe9b7kGmZMrgiCsCACfT7Ey
p3JjFKSSTUsEBmzg1+1A/yU=
=vx7Y
-----END PGP SIGNATURE-----



More information about the bazaar mailing list