Locales UTF8 - not working

Hello,

I'm facing a strange problem in one of my Debian server, what is happening right now it that I have runned dpkg-reconfigure locales to set en_US UTF-8 so in that way I could use accentuation in my system.

# locale -a
C
en_US.utf8
POSIX
pt_BR.utf8

However, when I create a new file via console like vi test and I try to use "�" or "�" for example the char is broken.

Any ideas?:wall:

The terminal has to support UTF8, too. What terminal are you using?

putty, however if I write "�" in the shell, it works, if I use echo "�" > test and cat test it works but if I do vi test and try "�" it fails.

# locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

What version of vi?

In vi, do:

:set encoding=utf8
# vi --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Jul 12 2010 12:49:33)
Included patches: 1-445

I did the

:set encoding=utf8

however that didn't work, my problem is, I have a script that have a email on it that when a user match a specific query, it sends an e-mail through exim. These e-mail is in Portuguese that is the reason that I'm getting this issue.

Any other ideas?

Did you check your putty setting under "window -> translation -> remote character set"?

Thanks for letting us know your actual problem.

The character set of the email has little to do with the character set of the system, by the way. You need to use MIME types to tell the email client the incoming data is UTF8 and not ASCII.

Yes, that is UTF-8.
I changed the locale again and now somethings are working.

Let me try to explain it better.
Right now I have this script:

...
cat <<EOF > $MESSAGE_FILE
Prezado(a) $NOME,

Usu�rio: $NAME
Celular : $PHONE
Valor : R$ $VALOR
Mes de Referencia: $REFERENCIA

Voc� est� recebendo esta notifica��o por estar em desacordo com a pol�tica de uso de celulares vigente da XXXX, no Brasil.  
O gasto mensal do seu celular est� acima do previsto pela pol�tica. 
Sugerimos que abra um chamado no help desk (8080) para que possamos adequar seus planos de voz e /ou dados � sua necessidade.

A pol�tica vigente encontra-se na p�gina web:

Atenciosamente,

IT Networks & Telecom

EOF

cat $MESSAGE_FILE | mailx -a "From: notreply@XXXX.com" notreply@XXXX.com -b AAAAA@XXXX.com -s "Uso de Celular Excedido em $REFERENCIA / Cell Phone Use Exceeded in $REFERENCIA"
...

If I create a test file that have the previous text and try the command line to send me the e-mail, the e-mail looks great, however when I run the script, the e-mail that I receive is broken:

Usu�o:
Celular : Linha
Valor : R$ DDD
Mes de Referencia: Commercial


Voc�st�ecebendo esta notifica� por estar em desacordo com a pol�ca
de uso de celulares vigente da XXXXX, no Brasil.  O gasto mensal do seu
celular est�cima do previsto pela pol�ca. Sugerimos que abra um chamado
no help desk (8080) para que possamos adequar seus planos de voz e /ou dados
�ua necessidade.

Any ideias?

In what way is it 'broken'? I can't see much wrong with it, except the R$, which I don't think ever worked.

1 Like

some graphic accents are missing, not the "�" but all the others are.

Should be:
Voc� est� recebendo esta notifica��o por estar em desacordo com a pol�tica de uso de celulares vigente da XXXX, no Brasil.

It is showing in the Inbox of the user:
Voc�st�ecebendo esta notifica� por estar em desacordo com a pol�ca de uso de celulares vigente da XXXXX, no Brasil.

The R$ is loaded with the rest of the script. Don't worry about it.

After the change of the locales the text in the script wasn't fixed so I had to update it manually and after that it worked.

Thank you in advance.

Wow. Feels great to read your blog.Actually I was searching for the same information since many days but todayI am so lucky to land on your page. Thanks again for your hard work.