Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove accents from string in C?

Is there is a more efficient way to remove accents from string without make an big array with the characters to replace?

For example:

removeaccents("áèfoo")

Output:

aefoo

In the ASCII table there no accents, I have no idea how to do this. Thanks in advance. :)

like image 538
Jack Avatar asked Mar 14 '12 03:03

Jack


People also ask

How do you remove accents in Java?

Use java. text. Normalizer to handle this for you. This will separate all of the accent marks from the characters.


1 Answers

Sounds like you're looking for unac(). From the man page:

unac is a C library that removes accents from characters, regardless of the character set (ISO-8859-15, ISO-CELTIC, KOI8-RU...) as long as iconv(3) is able to convert it into UTF-16 (Unicode).

I couldn't find the download page (I think it's meant to be here, but the link is currently 404ing). If you're on ubuntu, you can get it with:

sudo apt-get install libunac1-dev

Assuming you're using gcc, once it's installed you'll need to add -lunac to your compiler options (to tell the compiler to link with the unac library).

like image 127
Timothy Jones Avatar answered Nov 15 '22 07:11

Timothy Jones