Problem.
I am using Python 2.7 on Sublime Text 3 and have a print problem.
In some cases, I get pretty confusing output for '\uFFFD'
- 'REPLACEMENT CHARACTER'
.
For instance:
print u'\ufffd'
print u'\u0061'
-----------------------------------------------------
[Finished in 0.1s]
After inversion of order:
print u'\u0061'
print u'\ufffd'
-----------------------------------------------------
a
[Finished in 0.1s]
So, Sublime can print the "" character, but for some reason does not do this in the first case.
And the dependence of the output on the order of utterances seems rather strange.
The problem with replacing char leads to very unpredictable print quality in general.
For example, I want to print decoded bytes with error substitution:
cp1251_bytes = '\xe4\xe0'
print cp1251_bytes.decode('utf-8', errors='replace')
-----------------------------------------------------
[Finished in 0.1s]
Let me replace the bytes:
cp1251_bytes = '\xed\xe5\xf2'
print cp1251_bytes.decode('utf-8', errors='replace')
-----------------------------------------------------
[Finished in 0.1s]
And add another print statement:
cp1251_bytes = '\xed\xe5\xf2'
print cp1251_bytes.decode('cp1251')
print cp1251_bytes.decode('utf-8', errors='replace')
-----------------------------------------------------
[Finished in 0.1s]
The following is an illustration of the implementation of some other test cases:

To summarize , in the described print mode there are the following templates:
it depends on the even / odd number of characters '\uFFFD'
in the print instruction it depends on the print order it depends on the particular assembly
My questions:
Why is this happening? How to fix the problem?
My Python 2.7 sublime-build file:
{
"cmd": ["C:\\_Anaconda3\\envs\\python27\\python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"}
}
With Python 2.7 installed separately from Anaconda, the behavior is exactly the same.