avogadrolibs icon indicating copy to clipboard operation
avogadrolibs copied to clipboard

Plugin output to console doesn't use Unicode on Windows, Avogadro expects UTF-8

Open matterhorn103 opened this issue 1 year ago • 3 comments

See this issue on the avo_xtb plugin repo, helpfully raised by @Ineluki80.

It seems that on Windows, in at least some cases, the Python stdout stream isn't being encoded in UTF-8 but rather that of the system locale/extended ASCII, which means Unicode characters (e.g. the ellipsis for menu options) are being garbled.

The Python sys docs suggest that actually in many cases, UTF-8 is the default, so I'm not quite sure what's going on. In any case, it looks like there are various ways to enforce Unicode when calling the interpreter e.g. via an environment variable or a command line flag.

matterhorn103 avatar Feb 12 '24 19:02 matterhorn103

Okay, it looks like the code reading from Python scripts needs to use https://doc.qt.io/qt-6/qstring.html#fromLocal8Bit on Windows.

ghutchis avatar Feb 12 '24 19:02 ghutchis

I guess my one concern would be if scripts output UTF-8 (e.g., your recent fix) and Avogadro uses fromLocal8Bit that it again causes problems.

I'll add a pull request and we can see what happens

ghutchis avatar Feb 13 '24 20:02 ghutchis