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
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
11-11-2004, 09:57 AM
#1
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,524
Rep:
Converting extended ascii (ë,ô) in bash script
Hi,
I need to convert extended characters like ê ö (hope it displays in your browser) to their normal ones in a bash script. So: 'ë' becomes 'e', etc.
Can somebody tell mee how I could do that? Preferably using standard tools available (sed, awk, tr or similar)?
Thanks in advance.
11-11-2004, 11:39 AM
#2
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,524
Original Poster
Rep:
OK, I've already found a blunt solution that works (at least on SuSE's default charset), which is enough for me now. I discovered there no general way to do this.
For people interested:
Code:
#!/bin/bash
sed \
-e 's/ä/a/g' \
-e 's/á/a/g' \
-e 's/à/a/g' \
-e 's/â/a/g' \
\
-e 's/ë/e/g' \
-e 's/é/e/g' \
-e 's/è/e/g' \
-e 's/ê/e/g' \
\
-e 's/ï/i/g' \
-e 's/í/i/g' \
-e 's/ì/i/g' \
-e 's/î/i/g' \
\
-e 's/ö/o/g' \
-e 's/ó/o/g' \
-e 's/ò/o/g' \
-e 's/ô/o/g' \
-e 's/ø/o/g' \
\
-e 's/ü/u/g' \
-e 's/ú/u/g' \
-e 's/ù/u/g' \
-e 's/û/u/g' \
\
-e 's/ÿ/y/g' \
-e 's/ý/y/g' \
\
-e 's/ñ/n/g' \
\
-e 's/ÿ/y/g' \
-e 's/ý/y/g' \
\
-e 's/ñ/n/g' \
\
-e 's/ä/A/g' \
-e 's/Á/A/g' \
-e 's/À/A/g' \
-e 's/Â/A/g' \
\
-e 's/Ë/E/g' \
-e 's/É/E/g' \
-e 's/È/E/g' \
-e 's/Ê/E/g' \
\
-e 's/Ï/I/g' \
-e 's/Í/I/g' \
-e 's/Ì/I/g' \
-e 's/Î/I/g' \
\
-e 's/Ö/O/g' \
-e 's/Ó/O/g' \
-e 's/Ò/O/g' \
-e 's/Ô/O/g' \
-e 's/Ø/O/g' \
\
-e 's/Ü/U/g' \
-e 's/Ú/U/g' \
-e 's/Ù/U/g' \
-e 's/Û/U/g' \
\
-e 's/Ý/Y/g' \
\
-e 's/Ñ/n/g' \
\
"$0"
# End Of Script
11-11-2004, 12:06 PM
#3
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,524
Original Poster
Rep:
Better yet:
Code:
#!/bin/bash
sed \
-e 's/[äáàâ]/a/g' \
-e 's/[ëéèê]/e/g' \
-e 's/[ïíìî]/i/g' \
-e 's/[öóòôø]/o/g' \
-e 's/[üúùû]/u/g' \
-e 's/[ÿý]/y/g' \
-e 's/ñ/n/g' \
\
-e 's/[ÄÁÀÂ]/A/g' \
-e 's/[ËÉÈÊ]/E/g' \
-e 's/[ÏÍÌÎ]/I/g' \
-e 's/[ÖÓÒÔØ]/O/g' \
-e 's/[ÜÚÙÛ]/U/g' \
-e 's/Ý/Y/g' \
-e 's/Ñ/n/g' \
\
"$1"
Last edited by Hko; 11-11-2004 at 12:10 PM .
06-01-2009, 09:03 AM
#4
LQ Newbie
Registered: May 2009
Distribution: Ubuntu, CentOS, Redhat, Maemo
Posts: 10
Rep:
Quote:
Originally Posted by
Hko
Hi,
I need to convert extended characters like ê ö (hope it displays in your browser) to their normal ones in a bash script. So: 'ë' becomes 'e', etc.
Can somebody tell mee how I could do that? Preferably using standard tools available (sed, awk, tr or similar)?
Thanks in advance.
A little late, as usual, but this question was also asked in another thread. I posted the solution in that thread ->
http://www.linuxquestions.org/questi...ml#post3559031
Thread Tools
Search this Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT -5. The time now is 08:46 AM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News