python, ascii & unicode

Like me, perhaps you’ve been trying to serialize some data (in my case using vobject to create ical output) and ran into:

‘ascii’ codec can’t decode byte… blah blah

Well, I discovered a great way to do unicode conversion today and wanted to share. You can use smart_unicode() and force_unicode() to convert items prior to serialization or whatever else your requirement is. 

unicode_value = force_unicode(value)

Ta da.