ipython/ipython — Issue #1375: %history -g -f file encoding issue
Author: c000de
Created: 2012-02-04 18:13:27+00:00
State: open

When I tried to write my entire IPython history to a file using the %hist magic function, I get an encoding error:

```python
/usr/local/lib/python2.6/dist-packages/ipython-0.11-py2.6.egg/IPython/core/history.pyc in magic_history(self, parameter_s)
685 if multiline:
686 inline = "\n... ".join(inline.splitlines()) + "\n..."
--> 687 print(inline, file=outfile)
688 if get_output and output:
689 print(output, file=outfile)

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2014' in position 3929: ordinal not in range(128)
```

If you'd append line 676 to include an encoding to (say) UTF-8:

```python
inline = inline.expandtabs(4).rstrip().encode('utf8')
```

That would fix the issue. Hope this helps, and thanks for making IPython as awesome as it is!