How do I represent a Unicode character in a literal string ISO/ANSI C when the character set is ASCII?

c, unicode

Solution

For UTF8, you have to generate the encoding yourself using rules found, for example, here. For example, the German sharp s (ß, code point 0xdf), has the UTF8 encoding 0xc3,0x9f. Your e-acute (é, code point 0xe9) has a UTF8 encoding of 0xc3,0xa9.

And you can put arbitrary hex characters in your strings with:

char *cv = "r\xc3\xa9sum\xc3\xa9";
char *sharpS = "\xc3\x9f";

Problem

In Perl, I can say ``` my $s = "r\x{e9}sum\x{e9}"; ``` to assign `"résumé"` to `$s`. I want to do something similar in C. Specifically, I want to say ``` sometype_that_can_hold_utf8 c = get_utf8_char(); if (c < '\x{e9}') { /* do something */ } ```

Original source