On Sat, 2024-02-17 at 10:41 +0100, Enrico Forestieri wrote:
> On Fri, Feb 16, 2024 at 03:28:25PM +0000, José Matos wrote:
> > 
> > On Fri, 2024-02-16 at 15:23 +0200, Idan Pazi wrote:
> > > 
> > > Apparently, the returned value from win32file.ReadFile should be
> > > converted to a string. 
> > 
> > > Fix patch attached.
> > > Thank you, Idan
> > 
> > What is the encoding of the bytes? Is it UTF8?
> > If so the patch look right.
> > 
> > @Enrico, what do you think?
> 
> I don't have a native Windows python 3 installation and the python 
> distributed with LyX on Windows doesn't include PyWin extension
> modules. 
> Thus I cannot test that code. However, I don't think that 
> win32file.ReadFile() returns utf8. Most probably it returns some 8-
> bit 
> encoding corresponding to the current code page. But, even using 
> win32file.ReadFileW() (assuming it exists) that would return utf16.
> 
> -- 
> Enrico

@Idan, I agree with Enrico. So I am also puzzled why this works.

What is the output that you get from the following code?

import sys
print(sys.flags.utf8_mode)

The UTF-8 mode that was introduced in Python 3.7 and will be the
default in Python 3.15.

In https://docs.python.org/3/using/windows.html#win-utf8-mode

it reads:

"""
Note

Even when UTF-8 mode is disabled, Python uses UTF-8 by default on
Windows for:

* Console I/O including standard I/O (see PEP 528 for details).
* The filesystem encoding (see PEP 529 for details).
"""

So I am not sure if the code works because of the last remark...

-- 
José Abílio
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to