File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 1919def unic (item , * args ):
2020 # Based on a recipe from http://code.activestate.com/recipes/466341
2121 try :
22- return unicodedata .normalize (" NFC" , unicode (item , * args ))
22+ return unicodedata .normalize (' NFC' , unicode (item , * args ))
2323 except UnicodeError :
2424 try :
2525 ascii_text = str (item ).encode ('string_escape' )
2626 except UnicodeError :
27- return "<unrepresentable object '%s'>" % item .__class__ .__name__
27+ return u "<unrepresentable object '%s'>" % item .__class__ .__name__
2828 else :
2929 return unicode (ascii_text )
3030
Original file line number Diff line number Diff line change 11import unittest
2+ import unicodedata
23from robot .utils import unic , is_jython
34from robot .utils .asserts import assert_equals , assert_true
45if is_jython :
89
910
1011if is_jython :
11- class TestUnic (unittest .TestCase ):
12+ class TestJavaUnic (unittest .TestCase ):
1213
1314 def test_with_java_object (self ):
1415 data = u'This is unicode \xe4 \xf6 '
@@ -29,6 +30,13 @@ def test_with_iterator(self):
2930
3031class TestUnic (unittest .TestCase ):
3132
33+ def test_unicode_nfc_and_nfd_decomposition_equality (self ):
34+ text = u'Hyv\xe4 '
35+ assert_equals (unic (unicodedata .normalize ('NFC' , text )), text )
36+ # In Mac filesystem umlaut characters are presented in NFD-format.
37+ # This is to check that unic normalizes all strings to NFC
38+ assert_equals (unic (unicodedata .normalize ('NFD' , text )), text )
39+
3240 def test_object_containing_unicode_repr (self ):
3341 assert_equals (unic (UnicodeRepr ()), u'Hyv\xe4 ' )
3442
You can’t perform that action at this time.
0 commit comments