String from print() comes as Unicode while from raise Exception() as AnsiString #465
-
I have Unicode file sample.py with the following script inside:
In IO UnicodeIO is set to True. In OnSendUnicodeData() I simply dump all received messages into a text file. That's how it looks when I run the script: Some of the data comes in incorrect encoding. Any ideas how to solve this? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 14 replies
-
When I run your code with Demo01 I works well. I used
sample.py is utf8 encoded. Could you post a simple project in a zip file that reproduces the issue? |
Beta Was this translation helpful? Give feedback.
-
The script should be in the file and the script file name should be passed to the ExecStrings method as a parameter to reproduce the mistake. |
Beta Was this translation helpful? Give feedback.
-
I have not tested but you need to specify a UTF8 encoding in Script.LoadFromFile(aFileName); and TInputOutputStub.Output.SaveToFile('c:\Devel\tmp\PythonSample\sample.out') |
Beta Was this translation helpful? Give feedback.
-
the code you run is not the code you indent to run. The code you indent to run produces the output without that line. |
Beta Was this translation helpful? Give feedback.
-
You get that line in other cases e,g, sample.py sample.out
|
Beta Was this translation helpful? Give feedback.
-
The last thing.
|
Beta Was this translation helpful? Give feedback.
I have not tested but you need to specify a UTF8 encoding in
Script.LoadFromFile(aFileName);
and
TInputOutputStub.Output.SaveToFile('c:\Devel\tmp\PythonSample\sample.out')