v js by se to dalo napsat takto.
<script>
var woc, str, chr, tmp, n, out, outX;
woc = ' 0;+-=*/_.,?1;abcáč2;defďéě3;ghií4;jkl5;mnoňó6;pqrsřš7;tuvťúů8;wxyzýž9';
woc = woc.split(';');
for (i=0;i<woc.length;i++) {woc[i] = woc[i].split('');}
str = '24466651111111';
outX = '';
outX += str + "\n";
n = 0;
tmp = '';
out = '';
for (i=0;i<str.length;i++)
{
chr = str.charAt(i); // str[i]
if (tmp!=chr)
{
out += tmp!='' && woc[tmp*1] && woc[tmp*1][n] ? woc[tmp*1][n] : '';
n = 0;
tmp = chr;
}
else {
n++;
}
}
out += woc[tmp*1] && woc[tmp*1][n] ? woc[tmp*1][n] : '';
outX += out + "\n";
str = out;
//str = 'ahoj.';
out = '';
for (i=0;i<str.length;i++)
{
chr = str.charAt(i); // str[i]
for (j=0;j<woc.length;j++)
{
for (k=0;k<woc[j].length;k++)
{
if (chr==woc[j][k])
{
for (l=0;l<=k;l++)
{
out += '' + j;
}
break; break; // zastavit cyklus pro j, k
}
}
}
}
outX += out + "\n";
alert(outX);
</script>