var rules={"a":"a","ц":"ts", ... } function tr(s){return s.replace(/./g,function(c){ if(typeof rules[c] !=="undefined")return rules[c]; else return c; });}