Results 1 to 1 of 1
I thougth it concerned with bash scripting, but maybe this is the best forum for my question. I'm using: - Mandrake Linux 9.2 - Gnome 2.4 - Bash 2.05b.0(1) From ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-15-2004 #1
- Join Date
- Oct 2004
(GNOME), (GNOME) Terminal, UTF-8 and LANG variable
I thougth it concerned with bash scripting, but maybe this is the best forum for my question.
- Mandrake Linux 9.2
- Gnome 2.4
- Bash 2.05b.0(1)
From "Linux Programming & Scripting" forum
PostPosted: Wed Oct 13, 2004 1:57 pm Post subject: BASH, UTF-8 and portability
I'm writing an «interactive» bash script that does not contain any not-ascii (not-English) characters, but that uses external text files containing translations of the script answers into languages other than English. I like to encode every file using UTF-8 to avoid any problem with «every» language of the world, but different users use different locale settings (for example, I'm using ISO-8859-15 actually). How can my script tell the terminal to display UTF-8 files correctly? Or, if that were impossible, what could I do? Do you have different and better solutions? Thanks.
PostPosted: Wed Oct 13, 2004 2:07 pm Post subject:
bash is utf-8 aware if you use the correct locale setting. You have to use a UTF-8 locale.
This sets English (Great Britain) using UTF-8 charsets, for example.
PostPosted: Wed Oct 13, 2004 3:15 pm Post subject:
It doesn't work. An example.
Create a text file containing a single line:
VARIABLE="text with 'latin' characters other than English"
(where "text... OK it'clear... ).
Save it as FILE using UTF-8 (or ISO-8859-15 if your system default is UTF-8).
source FILE; echo $VARIABLE
My system default code is ISO-8859-15: I can't see the output correctly, whatever my LANG variable is.
Instead I can see the output correctly if I change my terminal options (I'm using GNOME Terminal: there is a submenu with a characters codes list); note that doing that LANG variable doesn't change.
PostPosted: Wed Oct 13, 2004 5:52 pm Post subject:
I think this has to do with gnome, not LANG.
LANG should work in console mode, unless X overrides settings.
What you said indicates this is happening.
I don't know anything about gnome, but there has to be some kind of an
.rc file for it - one that you described that you modified. Can you issue commands (equivalent of stty) that will make those changes to the gnome environment for the duration the shell script? And then turn them off.
It isn't your conventional environment it's your windowing envrionment.