t=Hash["\xe4\xb8\x80",1,"\xe4\xba\x8c",2,"\xe4\xb8\x89",3,"\xe5\x9b\x9b",4,"\xe4\xba\x94",5,"\xe5\x85\xad",6,"\xe4\xb8\x83",7,"\xe5\x85\xab",8,"\xe4\xb9\x9d",9,"",1] $<.each{|i| n=0 i=~/(.*)\xe5\x8d\x83(.*)/&&(n+=t[$1]*1000;i=$2) i=~/(.*)\xe7\x99\xbe(.*)/&&(n+=t[$1]*100;i=$2) i=~/(.*)\xe5\x8d\x81(.*)/&&(n+=t[$1]*10;i=$2) i=~/.+/&&n+=t[$&] puts n}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).