[patch] Re: Encoding woes

John Arbash Meinel john at arbash-meinel.com
Thu Jan 5 22:41:15 GMT 2006


Robert Collins wrote:
> On Tue, 2006-01-03 at 19:32 +1100, Robert Collins wrote:
> 
>>On Tue, 2006-01-03 at 01:37 -0500, Aaron Bentley wrote:
>>
>>>-----BEGIN PGP SIGNED MESSAGE-----
>>>Hash: SHA1
>>>
>>>Robert Collins wrote:
>>>| Other than that, how does that sound ?
>>>|
>>>| Do we have a +1 on this ?
>>>|
>>>| Are there any -1's ?
>>>
>>>+1
>>>
>>>I think it's the best thing we can do at the moment.  If it were easier
>>>to create unicode string literals, I'd be in favour of not converting,
>>>just requiring unicode.  This way still has some risk of encoding bugs.
>>
>>Yah, I understand and agree, but unfortunately is isn't easier - and
>>library users would also have to know.
>>
>>I'll test and code a routine for this on Wednesday, and we can start
>>plugging it in after that.
> 
> 
> Done - 'wednesday' ;).
> Http://people.ubuntu.com/~robertc/baz2.0/safe_unicode - ready for
> merging. (I'm going to get two +1s on the actual branch now ;))
> 
> (push is running now, be a few minutes to upload it) - but theres a
> patch attached for the impatient.
> 
> Cheers,
> Rob

I'll give you a +1, but I would like to see 1 small change, a unicode
string with non-ascii characters. It may not matter, but it would be nice.

...

> +
> +class TestSafeUnicode(TestCase):
> +
> +    def test_from_ascii_string(self):
> +        self.assertEqual(u'foobar', osutils.safe_unicode('foobar'))
> +
> +    def test_from_unicode_string(self):
> +        self.assertEqual(u'bargam', osutils.safe_unicode(u'bargam'))
> +
> +    def test_from_utf8_string(self):
> +        self.assertEqual(u'foo\xae', osutils.safe_unicode('foo\xc2\xae'))
> +
> +    def test_bad_utf8_string(self):
> +        self.assertRaises(BzrBadParameter, osutils.safe_unicode, '\xbb\xbb')
> 

John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060105/1db3f2f1/attachment.pgp 


More information about the bazaar mailing list