Conversation
| } | ||
|
|
||
|
|
||
| def encode_string_value(value: str, encoding: str): |
There was a problem hiding this comment.
This function is a just a proof of concept. The final version should look into the MathicsScanner tables
| value = value[1:-1] | ||
|
|
||
| if "encoding" in options and options["encoding"] != "Unicode": | ||
| value = encode_string_value(value, options["encoding"]) |
There was a problem hiding this comment.
Looking at this more closely, there may be a deeper problem here.
If the Mathics3 string was encoded with Unicode under the user's control, that should remain. If Mathics3 added the Unicode because an operator appeared, that is probably wrong, and the code that added the Unicode should be fixed.
So, what is a specific scenario or situation where line 200 is triggered?
There was a problem hiding this comment.
Line 200 is triggered when the required encoding is not the standard Unicode. It happens when the SystemCharacterEncoding is not Unicode (for example by setting MATHICS_CHARACTER_ENCODING="ASCII") or when it is call from ToString with a specific CharacterEncoding option.
There was a problem hiding this comment.
Line 200 is triggered when the required encoding is not the standard Unicode. It happens when the SystemCharacterEncoding is not Unicode (for example by setting
MATHICS_CHARACTER_ENCODING="ASCII") or when it is call fromToStringwith a specificCharacterEncodingoption.
This paraphrases the if condition. I meant, what is it that is causing an operator to get converted before ToString was called. This, I think, is the real source of the problem.
|
A suggestion for a check that things are fixed would be to run |
This PR covers #1678 by
SystemCharacterEncodinghas effect on the text renderCharacterEncodingoption inToStringworks as expected