Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C : Converting all special char to the equivalent (é => e)

Tags:

c

function

ascii

I need to code a Caesar cipher in C, so I'm working step by step to understand everything I'm doing.

I need to take care of special chars example : if a user enters

"This is a déjà vù !" it will convert this to "This is a deja vu"

Is there a C function capable of doing this instead of doing it by hand for each special char in ASCII code ?

This is what I'm trying to avoid :

case -85 :
case -86 :
case -87 :
case -88 :
    *p = 'e';
like image 468
sf_tristanb Avatar asked Feb 25 '23 22:02

sf_tristanb


1 Answers

Is there a C function capable of doing this instead of doing it by hand for each special char in ASCII code ?

Iconv will do what you want when you choose ASCII//TRANSLIT as the target encoding.

like image 53
sepp2k Avatar answered Mar 07 '23 14:03

sepp2k