LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-12-2008, 11:49 AM   #1
BlueberryPickles
LQ Newbie
 
Registered: Jul 2008
Posts: 4

Rep: Reputation: 0
Shell won't recognise foreign characters


Hi everyone,

I'm having a nightmare trying to write a shell script that, among other things, changes to a directory that has foreign characters in its name.

From Ubuntu's terminal, I can type:

$ cd Ontology/Top/World/Franšais/

and it moves me to my Franšais directory without a problem.

In my shell script, however, when I have:

#!/bin/sh

LC_ALL="fr_FR.UTF-8"

dir="Ontology/Top/World/Franšais/"

# Move to the top level of the ontology
cd $dir

# Find all of the categories at the top level of the ontology
ls > directories.tmp


I get the error message:

cd: 8: can't cd to Ontology/Top/World/Fran�ais/

Why won't my script let me use the š character when I can do it without a problem from the terminal?

Help please!
 
Old 07-12-2008, 02:18 PM   #2
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
I'm not a shell script master when it comes to using locales, but would you need to export the LC_ALL value - did you check that it's actually set?

EDIT: but if LC_ALL is set to that value when you run the script, it should be in use anyway if I'm not mistaken. Just as a guess, does the charset/keymap of your console (which sh uses; not necessarily the same that for example gnome-terminal uses) contain the glyph you're using?

Last edited by b0uncer; 07-12-2008 at 02:23 PM.
 
Old 07-12-2008, 03:07 PM   #3
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
or you can use a wildcard
 
Old 07-13-2008, 04:23 AM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
I had no trouble with the script (I added a mkdir to the script to create the directories for me):

Code:
$ cat doit.sh
#!/bin/sh

LC_ALL="fr_FR.UTF-8"

dir="Ontology/Top/World/Franšais/"
mkdir -p $dir

# Move to the top level of the ontology
cd $dir

# Find all of the categories at the top level of the ontology
ls > directories.tmp

$ ./doit.sh

$ LC_ALL="fr_FR.UTF-8" ls -R
Ontology/ doit.sh*

./Ontology:
Top/

./Ontology/Top:
World/

./Ontology/Top/World:
Fran\šais/

./Ontology/Top/World/Franšais:
directories.tmp
My sh is bash-based, perhaps yours is Bourne-shell based, or behaves in compatibility mode with called by /bin/sh. Try changing #!/bin/sh to #!/bin/bash
 
Old 07-14-2008, 04:52 AM   #5
BlueberryPickles
LQ Newbie
 
Registered: Jul 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Tried that, but no success...What did help was to change the foreign characters to character symbols! Not so readable but it worked...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ntfs-3g cannot access files with foreign characters dissociative Slackware 3 05-11-2008 11:26 PM
Accented Characters and other "foreign language" Characters Mark_in_Hollywood LQ Suggestions & Feedback 2 04-30-2007 07:10 PM
Centericq foreign characters messed up dlublink Linux - Software 2 02-24-2005 11:14 AM
Foreign Characters in Fedora RC2 bluemak Linux - Newbie 1 08-30-2004 09:37 AM
gnome-terminal and foreign characters b0uncer Linux - Software 0 05-06-2004 02:03 PM


All times are GMT -5. The time now is 08:55 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration