你可以用
str.charCodeAt(i)进行判断
类似于
http://www.csdn.net/Develop/read_article.asp?id=13104