Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Foreign Language Characte Substitution

Status
Not open for further replies.

ediman4902

Programmer
Jun 19, 2007
6
US
Is there a way in AWK to convert "ä" (umla-A) to "a" and for the rest of the European character set that use the "unla" like "O" and "U"?
 


Not very elegant, but you could try something like this:
Code:
cat - <<eofx >MyFile.txt
1-àèìòù-
2-áéíóú-
3-àèìòù-
4-âêîôû-
5-ãëïõü-
6-äåæö
eofx
echo "+-- MyFile.txt --------------------"
cat MyFile.txt
echo "+------------------------------"
awk '
BEGIN {
c["a"]="àáâãäåæ";
c["e"]="èéêë";
c["i"]="ìíîï";
c["o"]="òóôõö";
c["u"]="ùúûü";}
{r=$0; 
 for (x in c) {
   for (i=1;i<=length(c[x]);i++) {
     gsub(substr(c[x],i,1),x,r)}
 } print "+- %s"$0" to "r;
}' MyFile.txt
[thumbsup2]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top