I'm using iconv's transliterate function to convert a unicode string to the nearest ASCII equivalent. However, the string contains some symbols which do not have an ASCII equivalent. I want to retain such symbols without dropping them.
Currently, here's what I am doing:
iconv_t cd = iconv_open("ASCII//IGNORE//TRANSLIT", "UTF-8");
const char *utf8 = "ç ß ∑ a";
char* in = const_cast<char*>(utf8);
size_t in_bytes = strlen(in);
char buf[BUFSIZ] = {};
char* out = buf;
size_t out_bytes = sizeof(buf);
iconv(cd, &in, &in_bytes, &out, &out_bytes);
printf("%s", buf);
// prints
c ss a
How do I configure iconv to produce an output like the following:
c ss ∑
If this is not possible with iconv, is there a way to achieve this programatically otherwise?