Review: Needs Fixing

You need to check if the variable is a QString, not if it is not unicode.

   uni = unicode(string) # this is converts the str to unicode using the ASCII 
encoding, since none is specified
   uni = unicode(string, 'utf-8') # this converts to unicode using the 
specified UTF-8 encoding

QStrings behave differently. The Python version of a QString has a __unicode__ 
special method which is called when you typecast it to unicode. This means that 
you do not need to worry about what encoding to use, as the QString already 
knows what encoding it is use, and converts its content for you.

  uni = unicode(qstring) # This calls the qstring.__unicode__() method to 
return unicode.

Python knows how to compare str and unicode, so you don't need to worry about 
that. It is QStrings that Python does not know how to handle.
-- 
https://code.launchpad.net/~mahfiaz/openlp/unicode_warning_fix/+merge/84690
Your team OpenLP Core is subscribed to branch lp:openlp.

_______________________________________________
Mailing list: https://launchpad.net/~openlp-core
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to