UTF-8 & # 8594; ASCII in C

I have a simple question that I can not find anywhere on the Internet, how can I convert UTF-8 to ASCII (mostly accented characters with the same character without an accent) in C using only the standard lib? I found solutions for most languages, but not for C.

Thank!

EDIT: Some of those guys who commented made me double-check what I needed, and I'm exaggerated. I just need an idea on how to make a function that does: char with an accent → char without an accent. :)

+5
source share
5 answers

. UTF-8 ASCII, , ASCII.

, (, → a), .

+2

libiconv. , , .

+5

, . UTF-8 , .

+4

Unicode ( , ) KC KD. . . , , - , . , .

+2

Since this is homework, I assume that your teacher knows and knows nothing about UTF-8 and was probably stuck in the 1980s with “code pages” and “advanced ASCII” (words that you should remove from your vocabulary, if you have not already done so). Your teacher probably wants you to write a 128-byte lookup table that displays the bytes CP437 or Windows-1252 in the range 128-255 for similar ASCII letters. It will be like ...

void strip_accents(unsigned char *dest, const unsigned char *src)
{
    static const unsigned char lut[128] = { /* mapping here */ };
    do {
        *dest++ = *src < 128 ? *src : lut[*src];
    } while (*src++);
 }
+2
source

All Articles