user_encoding fix

Nir Soffer nirs at freeshell.org
Fri Feb 17 08:28:44 GMT 2006


I made another small fix, using always bzrlib.user_encoding for outf - 
the previous code used sys.stdout.encoding, which is ASCII here (on 
10.3).

See revno 1578 in http://nirs.dyndns.org/bzr/encoding-nirs

Here is an example usage with Hebrew name:

     $ ls | cat
     עברית
     Aluminum:~/Projects/bzr/hebrew-test nir$ ../encoding-nirs/bzr init
     Aluminum:~/Projects/bzr/hebrew-test nir$ ../encoding-nirs/bzr add *
     added "עברית"
     Aluminum:~/Projects/bzr/hebrew-test nir$ ../encoding-nirs/bzr 
commit -m 'added file named \327\242\327\221\327\250\327\231\327\252'
     Committed revision 1.
     Aluminum:~/Projects/bzr/hebrew-test nir$ ../encoding-nirs/bzr log   
            ------------------------------------------------------------
     revno: 1
     committer: Nir Soffer <nirs at freeshell.org>
     branch nick: hebrew-test
     timestamp: Fri 2006-02-17 10:11:34 +0200
     message:
       added file named עברית

Sweet :-)

I wonder what tests are missing for this - maybe  check that its 
possible to encode the file name into outf using the command encoding 
type? e.g does not raise UnicodeEncodeError


There is still an encoding error after editing the file and trying to 
diff:

     Aluminum:~/Projects/bzr/hebrew-test nir$ cat > 
\327\242\327\221\327\250\327\231\327\252
     עברית שפה קשה
     Aluminum:~/Projects/bzr/hebrew-test nir$ ../encoding-nirs/bzr 
diff=== modified file u'\u05e2\u05d1\u05e8\u05d9\u05ea'
     bzr: ERROR: exceptions.UnicodeEncodeError: 'ascii' codec can't 
encode characters in position 4-8: ordinal not in range(128)
       at /Volumes/Home/nir/Projects/bzr/encodings.nirs/bzrlib/diff.py 
line 60
       in internal_diff

Problems:
- the modified file line uses unreadable repr instead of encoded output
- Does diff support unicode content?


Best Regards,

Nir Soffer





More information about the bazaar mailing list