For my project, everything must be in unicode. Here is my way of handling everything, all strings are passed into this function:
def unicodify(string):
if not isinstance(string, unicode):
return string.decode('utf8', errors='ignore')
return string
Is the following method good practice for production code? If not, why and how would you suggest decoding to unicode? The errors='ignore' actually does not work for ValueErrors 'invalid \x escape', but i'm not sure how to properly handle that.
Thanks
.decode()method.