Am Dienstag, 17. Oktober 2017 um 00:20:02, schrieb Uwe Stöhr <uwesto...@web.de>
> El 16.10.2017 a las 23:38, Kornel Benko escribió:
> 
> > This leads to following output for e.g. Additional.lyx
> > b'#LyX 2.3 created this file. For more info see http://www.lyx.org/'
> 
> Hmm, but why do we need to modify the doc files? I mean why can't we 
> just use them as they are and omit ReplaceValues.py with Python 3?
> 

Its, because of problems we had with files having set \origin with wrong value.

> When playing ping pong like
> 
> testa = SubstituteDataInLine(line[:-1]).encode("utf-8")
> testb = testa.decode("utf-8")
> sys.stdout.write(testb)
>
> I get
> UnicodeEncodeError: 'charmap' codec can't encode character '\u014d'
> 
> so the SubstituteDataInLine routine does actually not only replace but 
> changes the encoding.

No, I think it is the write which tries to change encoding.
Nonetheless, the '\n' is missing in sys.stdout.write().
We could also use sys.stdout.buffer.write() here.

        for line in codecs.open(InFile, 'r', 'UTF-8'):
                text = SubstituteDataInLine(line[:-1]+'\n').encode('utf8')
                sys.stdout.buffer.write(text)

> I don't have ideas.

Read and write text are done according to lokale on your platform.
Could you try the following environments:
        PYTHONIOENCODING=utf-8

If everything fails, we could still use the perl version of the script.

> regards Uwe

PS.
And please don't commit until we have a solution working with python3 _and_ 
python2

        Kornel

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to