Re: WTF? Printing unicode strings
Ron Garret wrote:[color=blue][color=green][color=darkred]
> > > I'm using an OS X terminal to ssh to a Linux machine.[/color]
> >
> > In theory it should work out of the box. OS X terminal should set
> > enviromental variable LANG=en_US.utf-8, then ssh should transfer this
> > variable to Linux and python will know that your terminal is utf-8.
> > Unfortunately AFAIK OS X terminal doesn't set that variable and most
> > (all?) ssh clients don't transfer it between machines. As a workaround
> > you can set that variable on linux yourself . This should work in the
> > command line right away:
> >
> > LANG=en_US.utf-8 python -c "print unichr(0xbd)"
> >
> > Or put the following line in ~/.bashrc and logout/login
> >
> > export LANG=en_US.utf-8[/color]
>
> No joy.
>
> ron@www01:~$ LANG=en_US.utf-8 python -c "print unichr(0xbd)"
> Traceback (most recent call last):
> File "<string>", line 1, in ?
> UnicodeEncodeEr ror: 'ascii' codec can't encode character u'\xbd' in
> position 0: ordinal not in range(128)
> ron@www01:~$[/color]
What version of python and what shell do you run? What the following
commands print:
python -V
echo $SHELL
$SHELL --version
Ron Garret wrote:[color=blue][color=green][color=darkred]
> > > I'm using an OS X terminal to ssh to a Linux machine.[/color]
> >
> > In theory it should work out of the box. OS X terminal should set
> > enviromental variable LANG=en_US.utf-8, then ssh should transfer this
> > variable to Linux and python will know that your terminal is utf-8.
> > Unfortunately AFAIK OS X terminal doesn't set that variable and most
> > (all?) ssh clients don't transfer it between machines. As a workaround
> > you can set that variable on linux yourself . This should work in the
> > command line right away:
> >
> > LANG=en_US.utf-8 python -c "print unichr(0xbd)"
> >
> > Or put the following line in ~/.bashrc and logout/login
> >
> > export LANG=en_US.utf-8[/color]
>
> No joy.
>
> ron@www01:~$ LANG=en_US.utf-8 python -c "print unichr(0xbd)"
> Traceback (most recent call last):
> File "<string>", line 1, in ?
> UnicodeEncodeEr ror: 'ascii' codec can't encode character u'\xbd' in
> position 0: ordinal not in range(128)
> ron@www01:~$[/color]
What version of python and what shell do you run? What the following
commands print:
python -V
echo $SHELL
$SHELL --version
Comment