← Back to team overview

spv-dev team mailing list archive

[Branch ~bouf10/slidepresenterview/refactor-pres-design] Rev 64: Try to fix the problem with Unicode comparison using NFC unicode normalization.

 

------------------------------------------------------------
revno: 64
committer: F.-A. Bourbonnais <bouf10pub@xxxxxxxxxxx>
branch nick: refactor-pres-design
timestamp: Sun 2010-05-16 23:38:20 -0400
message:
  Try to fix the problem with Unicode comparison using NFC unicode normalization.
modified:
  slidepresenterview/utils/uri.py


--
lp:~bouf10/slidepresenterview/refactor-pres-design
https://code.launchpad.net/~bouf10/slidepresenterview/refactor-pres-design

Your team SlidePresenterView Development Team is subscribed to branch lp:~bouf10/slidepresenterview/refactor-pres-design.
To unsubscribe from this branch go to https://code.launchpad.net/~bouf10/slidepresenterview/refactor-pres-design/+edit-subscription
=== modified file 'slidepresenterview/utils/uri.py'
--- slidepresenterview/utils/uri.py	2010-05-17 03:10:40 +0000
+++ slidepresenterview/utils/uri.py	2010-05-17 03:38:20 +0000
@@ -115,4 +115,17 @@
     
     
     def __cmp__(self, other_uri):
-        return cmp(unicode(self.uri), unicode(other_uri.uri))
\ No newline at end of file
+        import unicodedata, sys
+        
+        if not isinstance(other_uri.uri, unicode):
+            other_uri_unicode = unicode(other_uri.uri, sys.stdout.encoding)
+        else:
+            other_uri_unicode = other_uri.uri
+            
+        if not isinstance(self.uri, unicode):
+            uri_unicode = unicode(self.uri, sys.stdout.encoding)
+        else:
+            uri_unicode = self.uri
+            
+        return cmp( unicodedata.normalize('NFC', uri_unicode),
+                    unicodedata.normalize('NFC', other_uri_unicode) )
\ No newline at end of file