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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace accent character "é" with "e"

Status
Not open for further replies.

BauV

Technical User
Aug 25, 2021
8
0
0
US
hi,

I need to replace accent character "é" with "e" (I know this is not correct replacement) in my file after converting it from utf-8 to ascii.
Any help is appreciated, thanks in advance.

Command used for conversion: $iconv -c -f utf-8 -t ascii < file1.txt > file2.txt

Cheers,
BauV
 
Hi

Try this, worked for my test text :
Code:
iconv -f utf-8 -t ascii[highlight]//translit[/highlight] < file1.txt > file2.txt

Feherke.
feherke.github.io
 
Thanks Fuherke, for the help.
I did try this already, shown with Error: tomap cannot be specified with fromcode.
Any further help is appreciated.

Cheers,
BauV
 
Try unaccent:
Code:
$ echo 'xáéíy' | unaccent utf-8
xaeiy
 
Try sed:
Code:
$ echo 'xáéíy' | sed 'y/áéí/aei/'
xaeiy
 
Thanks mikrom.
Both are showing errors, as below -
1) $ echo 'xáéíy' | unaccent utf-8 ---error: "ksh: unaccent: not found"
2) $ echo 'xáéíy' | sed 'y/áéí/aei/' ---error: sed: command garbled: y/áéí/aei/

I tried below command:
echo 'xá sdfdsédsfjdks íy' | sed -e 's/é/e/g' ---worked fine, result: "xá sdfdsedsfjdks íy"
sed -e 's/é/e/g' file1.txt > file1.res --- no luck
or
sed -e 's/é/e/g' < file1.txt > file1.res --- no luck

Any further suggestion plzz.

Cheers,
BauV
 
hi,

$file file1.txt --- says, English text or ASCII text
Does this matter?

Cheers,
BauV
 
ksh: unaccent: not found
Before I used it I had to install it on my Linux machine
Code:
sudo apt install unaccent
 
Unfortunately I do not have required access to install unaccent.
Cheers,
BauV.
 
BauV said:
$file file1.txt --- says, English text or ASCII text
Does this matter?
Yes, it does matter. How it could be english ASCII containing accents áéí? Such characters are not in english ASCII encoding.
My file is in utf-8 and everything works.
Code:
$ echo 'xáéíy' > file1.txt
$ file -i file1.txt 
file1.txt: text/plain; charset=utf-8
$ sed 'y/áéí/aei/' file1.txt 
xaeiy
$ sed 'y/áéí/aei/' file1.txt > file2.txt
$ cat file1.txt file2.txt 
xáéíy
xaeiy
$ file -i file*.txt 
file1.txt: text/plain; charset=utf-8
file2.txt: text/plain; charset=us-ascii

.. and what is your operating system ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top