windows preview bug fix

Enrico Forestieri forenr at lyx.org
Sat Feb 24 20:51:32 UTC 2024


On Sat, Feb 24, 2024 at 01:17:56PM +0200, Idan Pazi wrote:
> 
>I have sys.flags.utf8_mode = 0.
>I assume everything is utf8, but I don't think the problem is about 
>finding the right encoding.

On the contrary, it is necessary to know the initial encoding of a bytes 
object for converting it to unicode. However, your patch may actually be 
correct (despite sys.flags.utf8_mode = 0). I just launched the native 
python 3 interpreter distributed with lyx and did:

>>> import sys
>>> print(sys.stdin.encoding)
utf-8

So, the input encoding seems to actually be utf-8. In this case your 
patch is right.

Wanting to be very safe, we could use te chardet library for performing 
the correct conversion, but if the above is the standard with python 3 
on windows I don't think it is necessary.

-- 
Enrico


More information about the lyx-devel mailing list