Kodi Community Forum

Full Version: Need help with UnicodeError using xbmcvfs.rename
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm not a python developper and I imagine it's a newbie question, but I can't fin any answer to my problem, or I can't understand it and I need someone to explain me like I'm six.

So I would like to rename some files but files with name that contains some characters like single quotes triggers UnicodeDecodeError.
I tried with kodi.six but I still have the issue.

I also tried to encode them but with no success.

python:
xbmcvfs.rename(folder2 + "/" + file, folder2 + u"/" + newFileName)

Can someone help me with this ?
The difference between byte and text strings and the respective design flaws of Python 2 require a lecture of its own.  But since Kodi 19 Matrix release is not far away I'd recommend to forget about Python 2 and all its str/unicode mess. Use Python 3 for your addon.
(2021-02-08, 00:11)Roman_V_M Wrote: [ -> ]The difference between byte and text strings and the respective design flaws of Python 2 require a lecture of its own.  But since Kodi 19 Matrix release is not far away I'd recommend to forget about Python 2 and all its str/unicode mess. Use Python 3 for your addon.

Thank you for your answer.
I thank kodi.six would have fix the str/unicode mess.
(2021-02-08, 10:23)jona303 Wrote: [ -> ]I thank kodi.six would have fix the str/unicode mess.
kodi_six normalizes strings passed to/from Kodi API functions/methods. It does not address the flaws of Python 2 itself. That would require re-writing the whole language runtime and it has already been done (Python 3.x).