GNU/screen & UTF-8
In a GNU/screen session on this box, this happens sometimes:
$ rm foo rm: remove regular empty file ?foo??Why does it show a question mark instead of an apostrophe?
Running the same command with a different or no LANG setting seems to help:
$ LANG=C rm foo rm: remove regular empty file 'foo'? $ LANG="" rm foo rm: remove regular empty file 'foo'? $ echo $LANG en_US.UTF-8I usually start my screen sessions with
-U
:
> Run screen in UTF-8 mode. This option tells screen that your terminal sends and > understands UTF-8 encoded characters. It also sets the default encoding for new > windows to ‘utf8’.So, we have
LANG
set to en_US.UTF-8
and screen(1)
started in UTF-8 mode and still have character issues? Weird. But then I remembered: I use -U
only when starting the screen
session, not when resuming the session:
% screen -US MySession $ echo $LANG; rm foo en_US.UTF-8 rm: remove regular empty file 'foo'?Upon resuming the session with
"screen -dr"
the question marks were back again. Resuming with -Udr
fixes that.A more simple test may be just to print some characters:
$ echo -e '\xe2\x82\xac' € $ screen -S foo # echo -e '\xe2\x82\xac' � ^ad $ screen -Udr foo # echo -e '\xe2\x82\xac' â¬And conversely, this time we start our session in UTF-8 mode:
$ screen -US foo # echo -e '\xe2\x82\xac' € ^ad $ screen -dr foo # echo -e '\xe2\x82\xac' ?