Posts: 993
Joined: Nov 2014
Reputation:
20
2021-08-29, 20:14
(This post was last modified: 2021-08-30, 14:16 by burekas.)
Hi,
Everytime when I try to convert an old addon to Kodi 19 Matrix,
I always gets errors regarding the decoding/encoding => decode("utf-8"), decode('utf-8'), encode("utf-8"), encode('utf-8')
My question is: Does it not need to be set anymore?
Does it ok to make a search and remove all the shows of these?
Thanks.
Posts: 993
Joined: Nov 2014
Reputation:
20
Thanks Jeff.
By the way, look for all the cases the old addon code:
.decode("utf-8")
.encode("utf-8")
.decode('utf-8')
.encode("utf-8")
Posts: 1,692
Joined: Jun 2011
Reputation:
123
It depends on the context but generally converting binary strings to text ones is not necessary in Kodi Python API based on Python 3. Previously, before "Matrix" version Kodi Python API was a mess when it came to string handling and ad-hoc binary->text and text->binary string conversion was necessary in some cases. For example. xbmc.log() accepted only utf-8 encoded binary strings and implicit conversion failed if a text string (Python 2 unicode type) passed to xbmc.log() inlcuded characters outside ASCII encoding table.
Now Kodi Python API deals with text strings (Python 3 str type) in most cases and binary srings are needed only in special cases like reading/writing binary files or handling encryption keys in xbmcdrm module.