%{ #include #include void put_utf8(int); %} %START SKT %% "" BEGIN SKT; "" BEGIN 0; "E" { putchar('a'); putchar('i'); } "O" { putchar('a'); putchar('u'); } "K" { putchar('k'); putchar('h'); } "G" { putchar('g'); putchar('h'); } "C" { putchar('c'); putchar('h'); } "J" { putchar('j'); putchar('h'); } "T" { putchar('t'); putchar('h'); } "D" { putchar('d'); putchar('h'); } "P" { putchar('p'); putchar('h'); } "B" { putchar('b'); putchar('h'); } "W" { put_utf8(0x1e6d); putchar('h'); } // asp. retro. t "Q" { put_utf8(0x1e0d); putchar('h'); } // asp. retro. d "/a" { put_utf8(0x00e1); } // + acute acc. "/i" { put_utf8(0x00ed); } "/u" { put_utf8(0x00fa); } "/f" { put_utf8(0x1e5b); put_utf8(0x0301); } // syll. r "/x" { put_utf8(0x1e37); put_utf8(0x0301); } // syll. l "/A" { put_utf8(0x0101); put_utf8(0x0301); } // long a "/I" { put_utf8(0x012b); put_utf8(0x0301); } // long i "/U" { put_utf8(0x016b); put_utf8(0x0301); } // long u "/F" { put_utf8(0x1e5d); put_utf8(0x0301); } // long syll. r "/X" { put_utf8(0x1e39); put_utf8(0x0301); } // long syll. l "/e" { put_utf8(0x00e9); } "/o" { put_utf8(0x00f3); } "/E" { putchar('a'); put_utf8(0x00ed); } "/O" { putchar('a'); put_utf8(0x00fa); } "^a" { put_utf8(0x00e0); } // + grave acc. (indicates svarita) "^i" { put_utf8(0x00ec); } "^u" { put_utf8(0x00f9); } "^f" { put_utf8(0x1e5b); put_utf8(0x0300); } // syll. r "^x" { put_utf8(0x1e37); put_utf8(0x0300); } // syll. l "^A" { put_utf8(0x0101); put_utf8(0x0300); } // long a "^I" { put_utf8(0x012b); put_utf8(0x0300); } // long i "^U" { put_utf8(0x016b); put_utf8(0x0300); } // long u "^F" { put_utf8(0x1e5d); put_utf8(0x0300); } // long syll. r "^X" { put_utf8(0x1e39); put_utf8(0x0300); } // long syll. l "^e" { put_utf8(0x00e8); } "^o" { put_utf8(0x00f2); } "^E" { putchar('a'); put_utf8(0x00ec); } "^O" { putchar('a'); put_utf8(0x00f9); } "`a" { put_utf8(0x00e0); } // + grave acc. "`i" { put_utf8(0x00ec); } "`u" { put_utf8(0x00f9); } "`f" { put_utf8(0x1e5b); put_utf8(0x0300); } // syll. r "`x" { put_utf8(0x1e37); put_utf8(0x0300); } // syll. l "`A" { put_utf8(0x0101); put_utf8(0x0300); } // long a "`I" { put_utf8(0x012b); put_utf8(0x0300); } // long i "`U" { put_utf8(0x016b); put_utf8(0x0300); } // long u "`F" { put_utf8(0x1e5d); put_utf8(0x0300); } // long syll. r "`X" { put_utf8(0x1e39); put_utf8(0x0300); } // long syll. l "`e" { put_utf8(0x00e8); } "`o" { put_utf8(0x00f2); } "`E" { putchar('a'); put_utf8(0x00ec); } "`O" { putchar('a'); put_utf8(0x00f9); } "f" put_utf8(0x1e5b); // syll. r "x" put_utf8(0x1e37); // syll. l "A" put_utf8(0x0101); // long a "I" put_utf8(0x012b); // long i "U" put_utf8(0x016b); // long u "F" put_utf8(0x1e5d); // long syll. r "X" put_utf8(0x1e39); // long syll. l "N" put_utf8(0x1e45); // vel. n "Y" put_utf8(0x00f1); // pal. n "w" put_utf8(0x1e6d); // retro. t "q" put_utf8(0x1e0d); // retro. d "R" put_utf8(0x1e47); // retro. n "S" put_utf8(0x015b); // sch "z" put_utf8(0x1e63); // sh "H" put_utf8(0x1e25); // visarga "M" put_utf8(0x1e43); // anusvara "'" ECHO; // avagraha "L" put_utf8(0x1e37); // retro. l (Vedic) "|" { put_utf8(0x1e37); putchar('h'); } "~" put_utf8(0x0303); // combining tilde "\\" { } // consume . ECHO; \n { ECHO; fflush(stdout); } %% void put_utf8(int in) { char out[7]; int count; int mask = 0x3f; if (in <= 0x7f) { count = 1; out[0] = in; } else if (in >= 0x80 && in <= 0x7ff) { count = 2; out[1] = (in & mask) | 0x80; out[0] = ((in >> 6) & mask) | (0xf << (8 - count)); /* 0xc0; */ } else if (in >= 0x800 && in <= 0xffff) { count = 3; out[2] = (in & mask) | 0x80; out[1] = ((in >> 6) & mask) | 0x80; out[0] = ((in >> 12) & mask) | (0xf << (8 - count)); /* 0xe0; */ } out[count] = '\0'; printf("%s", out); /* printf("%x %x\n", 0xc0, ((0x0f << 5) & 0xff)); */ }