Pro un explication, vide illac.
/* Le . Variante plus simplice de lfn-cyr.c Face solo interlingua al scriptura grec secunde le schema 2. Vide https://rudhar.com/lingtics/intrlnga/scrptura/ia023.htm#Scripturas2 . Usa entitates symbolic in vice numeric, ubi possibile. */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <ctype.h> char *conv_table[] = { /* a */ "alpha", /* b */ "beta", /* c */ "#x3f2", /* d */ "delta", /* e */ "epsilon", /* f */ "phi", /* g */ "gamma", /* h */ "eta", /* i */ "iota", /* j */ "chi", /* k */ "kappa", /* l */ "lambda", /* m */ "mu", /* n */ "nu", /* o */ "omicron", /* p */ "pi", /* q */ "#x3d9", /* r */ "rho", /* s */ "sigma", /* t */ "tau", /* u */ "upsilon", /* v */ "#x3dd", /* w */ "omega", /* x */ "xi", /* y */ "psi", /* z */ "zeta", /* safety stop */ NULL }; static int convert (int c, FILE *fpi, FILE *fpo); int main (int argc, char **argv) { FILE *fpi = stdin, *fpo = stdout; int c; int intag = 0, inentity = 0; while ((c = getc(fpi)) != EOF) { if (!intag && c == '<') intag = 1; else if (intag && c == '>') intag = 0; else if (!inentity && c == '&') inentity = 1; else if (inentity && c == ';') inentity = 0; if (intag || inentity) putc(c, fpo); else convert(c, fpi, fpo); } return 0; } static int convert (int c, FILE *fpi, FILE *fpo) { if (!isascii(c) || !isalpha(c)) { putc(c, fpo); } else { int index; char *tabval; char buf[8]; index = c - (isupper(c) ? 'A' : 'a'); /* Safety first */ if (index >= 26) index = 26; tabval = conv_table[index]; if (!tabval) { putc(c, fpo); } else { int n; sprintf(buf, "&%s;", tabval); if (isascii(c) && isupper(c)) { if (c == 'C') strcpy(buf, "Ϲ"); else if (c == 'Q') strcpy(buf, "Ϙ"); else if (c == 'V') strcpy(buf, "Ϝ"); else buf[1] = toupper(buf[1]); } if (c == 's') { n = getc(fpi); if (!isalpha(n)) { /* Final lowercase sigma as in real Greek */ strcpy(buf, "ς"); } ungetc(n, fpi); } fprintf(fpo, "%s", buf); } } return 0; }