Platform Development • Re: I created a Python 3 port of UXP out of boredom...
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x91 in position 3: invalid start byte
Was about to forward the idea to try detecting byte string encoding first using chardet.detect() and selecting best confidence, then pass selected encoding to decode() instead of utf-8. However a quick test revealed the fact that chardet is no longer part of the default Python3 installation at least since Python 3.9 if not earlier. Substitutes could be charset_normalizer or cchardet but those are external modules too. Dunno of any similar other default module that'd be available in all [usable] Python3 versions. Which means, even trying to install any of those modules in the venv might fail if the user has no Internet access.
Or am I way off-track here? Can a prebuilt venv be deployed with the UXP code so that all necessary Python modules would be readily available? Maybe that's already the case, dunno.
I removed "sys.stderr.write(stdout.decode(encoding='utf-8'))" line from file expandlibs_exec.py and the build was successful.
That line seems to only serve for debugging so it seems safe to omit it, but it may be better to use the correct character decoding so any error/debug/info message could be displayed as intended.
I also noticed a peculiarity that in the source files the files have a “0x0A” line ending. After building and packaging, all files began to have line ending “0x0D 0x0A”.
Source files use *nix line-ending by default. SInce you're using Windows it makes sense that resulting files would have a Windows line-ending.
Discussion in the ATmosphere