Maybe I'm missing something obvious, but is there a "painless" way to replace the accented letters in a given text with their unaccented counterparts? I can only use the standard ANSI C libraries/headers, so my hands are tied. What I've tried so far:
unsigned char currentChar;
(...)
if (currentChar == 'à') {
currentChar = 'a';
}
else if (currentChar == 'è' || currentChar == 'é') {
currentChar = 'e';
}
else if (...)
However, this doesn't work. Detecting accented vowels with their extended ASCII value isn't an option, either, as I've noticed that it changes depending upon the system locale.
Any hints/suggestions?
(update)
Thanks for the answers, but I'm not really asking for the best approach for this problem - I'll think about it later. I'm simply asking for a way to detect the accented vowels, as the code above simply ignores them.
(update #2)
Okay. Let me clarify:
#include <stdio.h>
int main(void) {
int i;
char vowels[6] = {'à','è','é','ì','ò','ù'};
for (i = 0; i < 6; i++) {
switch (vowels[i]) {
case 'à': vowels[i] = 'a'; break;
case 'è': vowels[i] = 'e'; break;
case 'é': vowels[i] = 'e'; break;
case 'ì': vowels[i] = 'i'; break;
case 'ò': vowels[i] = 'o'; break;
case 'ù': vowels[i] = 'u'; break;
}
}
printf("\n");
for (i = 0; i < 6; i++) {
printf("%c",vowels[i]);
}
printf("\n");
return 0;
}
This code still prints "àèéìòù" as its output. This is my problem. I appreciate the answers, however it's pointless to tell me to implement a conversion map, or a switch/case structure. I'll think about it later.