<div dir="ltr"><div>I'm interested about why IPython (python 2) does ascii encoding the way it does.</div><div><br></div>When I run ipython in a ascii terminal and enter a byte greater than 127, it appears to be decoded using latin-1 and re-encoded with utf8.<div>

<br></div><div>    In [1]: '<meta-a, or byte \xe1>'</div><div>    Out [1]: '\xef\xbf\xbd'</div><div><br></div><div>In a ascii-encoded python file, this would be an error. In an ASCII vanilla Python interpreter, this would be just the byte entered, '\xe1'. In terminal ipython, just entering the byte (without quotes) gives ERROR - failed to write data to stream. In vanilla ascii python, this would be a syntax error.</div>

<div><br></div><div>I'm interested in why this decision was made. I'm in the process of choosing a behavior for bpython, and so far can think of:</div><div><br></div><div>1) vanilla python 2 behavior - run source code as bytes when terminal is ascii encoded</div>

<div>2) vanilla python 3 behavior - syntax error on finding this character</div><div>3) ipython behavior - somehow figure out (guess? what happens in ipython?) which character is being represented on the user's terminal by this byte and decode it to unicode, then rencode it (all assuming it's in a string). I don't understand the specifics of this.</div>

<div><br></div><div>I'm particularly interested in whether it's important functionality to users (maybe for localization? do some people's terminals say ASCII but really represent important characters they can enter with their keyboards?)</div>

<div><br></div><div>Thanks very much for any thoughts,</div><div><br></div><div>-Tom</div></div>