diff options
author | David Wührer <def@gmx.at> | 2017-02-19 15:23:48 +0100 |
---|---|---|
committer | David Wührer <def@gmx.at> | 2017-02-19 15:23:48 +0100 |
commit | ed28bd25e3055ff9134eb655be37c076f9bf67fe (patch) | |
tree | 9099df56945f4274c21f6a368ab2d431282453eb /uryuomoco2english.c |
initial commit
Diffstat (limited to 'uryuomoco2english.c')
-rw-r--r-- | uryuomoco2english.c | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/uryuomoco2english.c b/uryuomoco2english.c new file mode 100644 index 0000000..c373bc0 --- /dev/null +++ b/uryuomoco2english.c @@ -0,0 +1,157 @@ +#include <stdio.h> +#include <ctype.h> + +// uryuomoco to english +// abcdefghijklmnopqrstuvwxyz +char trl[]="uvsjohtfydprnmekwlcgabqzix"; + +/* + * a->u + * ais->ss + * b->v + * c->s + * ch->th + * d->j + * e->o + * f->h + * g->t + * gis->ts + * h->f + * i->y + * ja->d + * k->p + * l->r + * m->n + * n->m + * o->e + * ot ->ing + * p->k + * qu->w + * quo->wh + * r->l + * ra->ll + * s->c + * se->ch + * t->g + * tul->gr + * u->a + * us->sh + * v->b + * w->qu + * x->z + * y->i + * z->x + */ + +int tr(int c){ + int retval; + static int prev=0; + static int prevprev=0; + if(islower(c)){ + switch(c){ + case 'a': + if(prev=='j') break; // ja->d + else if(prev=='r') retval=putchar('l'); // ra->ll + else{ // ais->ss, a->u, + c=getchar(); + if(c=='i'){ // ai + c=getchar(); + if(c=='s'){ // ais + putchar('s'); + retval=putchar('s'); + break; + }else{ // ai? + putchar('u'); + retval=putchar('y'); + } + }else{ // a? + retval=putchar('u'); + } + return tr(c); + } + break; + case 'c': + c=getchar(); + if(c=='h'){ // ch->th + putchar('t'); + retval=putchar('h'); + }else{ // c->s + putchar('s'); + return tr(c); + } + break; + case 'e': retval=putchar(prev=='s'?'h':'o'); break; // se->ch, s->c + case 'h': retval=(prevprev=='m'&&prev=='e'?'f':putchar('f')); break; // meh -> no , h->f + case 'i': + if(prev=='g'){ // gi + c=getchar(); + if(c=='s'){ // gis -> ts + retval=putchar('s'); + }else{ // gi? + putchar('y'); // i->y + return tr(c); + } + }else retval=putchar('y'); // i->y + break; + case 'o': + if(prevprev=='q'&&prev=='u') retval=putchar('h'); // quo->wh + else{ + c=getchar(); + if(c=='t'){ // ot + c=getchar(); + if(!islower(c)){ // -ot -> -ing + putchar('i'); + putchar('n'); + putchar('g'); + retval=putchar(c); + }else{ // ot? + putchar('e'); + putchar('g'); + prev='t'; + return(tr(c)); + } + }else{ + putchar('e'); // o->e + prev='o'; + return(tr(c)); + } + } + break; + case 'u': if(prev=='q') break; // qu->w + else if(prev=='y') break; // yu->i + c=getchar(); + if(prev=='t'){ // tu + if(c=='l'){ // tul->gr + retval=putchar('r'); + }else{ // tu? + putchar('a'); + prev='u'; + return tr(c); + } + }else{ // u + if(!islower(prev)&&c=='s'){ // us-> sh + putchar('s'); + retval=putchar('h'); + }else{ // u->a + putchar('a'); + prev='u'; + return tr(c); + } + } + break; + case 'w': putchar('q'); retval=putchar('u'); break; // w -> qu + default: retval=putchar(trl[c-'a']); // single to single + } + }else retval=putchar(c); + prevprev=prev; + prev=c; + return retval; +} + +int main(int argc, char** argv){ + char c; + do{ + c=getchar(); + }while(c!=EOF && tr(c)!=EOF); + return 0; +} |