Question regarding decoding/encoding: utf-8
#1
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.
Reply
#2
(2021-08-29, 20:14)burekas Wrote: Hi,

Everytime when I try to convert an old addon to Kodi 19 Matrix,
I always gets errors regarding the decoding => decode("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 this ".decode("utf-8")"?

Thanks.

In general, yes, remove all utf-8 encoding / decoding.  Unicode is native to Python 3 which Kodi 19 is based upon.  The exceptions are when you are talking to things outside of your addon (i.e. URLs, APIs etc..).  The need there will be based upon what they require.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#3
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")
Reply
#4
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.
Reply

Logout Mark Read Team Forum Stats Members Help
Question regarding decoding/encoding: utf-80