Terminal emacs woes: paste julia output gives char-or-string-p error, \u2502 displays, etc

this is not a julia problem, but an emacs (utf8) problem using julia, but I was hoping someone had an answer for this. I use macos, iterm2 and terminal.

Copy the output of d= DataFrame( x=1:3 )

10×1 DataFrames.DataFrame
│ Row │ x  │
│ 1   │ 1  │
│ 2   │ 2  │
│ 3   │ 3  │

Now paste it into a terminal shall via cat > /dev/null and it works fine (suggesting that the terminal emulator and the bash configuration are all ok). Paste it into a Quartz emacs.app and it works fine, too (suggesting emacs is just fine, too).

but try pasting it into a terminal emacs, and hell breaks loose Wrong type argument: char-or-string-p, 134217795. Unlike quartz emacs, the terminal emacs also displays UTF-8 characters badly, for example, with \u2502 instead of the vertical line. Pretty sure this is related.

there are apparently many moving parts here–utf8, terminal emulation, bash, and emacs. I have tried a whole host of related configurations, but have not stumbled onto the right ones.

what config does it take to convince terminal emacs to be julia-utf8 friendly? help, as always, appreciated.


Can’t reproduce on Emacs 25.2.2, I just get syntax errors.

Also, why would I want to do this? What do you expect the REPL to do with something that is not valid Julia code?

hi tamas—I am sorry for the confusion. I don’t mean pasting this into a julia REPL window. Just paste it into a text window. I am just trying to write explanations that are interspersed with Julia output.


I am not sure this is a Julia issue then. Also, it seems that you have a solution with the GUI version of Emacs, why can’t you just use that?

1 Like

FWIW, this works fine in linux with gnome terminal.

1 Like

I am sure—this is not a julia issue. I had just hoped that others had run into the same problem and solved it. (I often work on a remote terminal, rather than a GUI, which is why this is very inconvenient. thanks, antoine, too: it is a weird combination problem of iterm2 and term-emacs, then…grrr.)

The answer are the following entries in the .emacs.d/init.el

(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)

(define-coding-system-alias 'UTF-8 'utf-8)