mikael
Jan 02, 2018 - 00:42
Receiving NSData as _data, containing an encoded UTF-8 string as bytes, I ended up doing this to get back the original string:
decoded_data = bytearray(base64.b16decode(str(ObjCInstance(_data).CKUppercaseHexStringWithoutSpaces()))).decode()
I.e.:
- Convert to hex string (uppercase for b16decode)
- Convert to Python string
- Decode back to bytes
- Create a bytearray object
- Finally decode as UTF-8 string
There must be a simpler way?