Created
July 28, 2015 08:36
-
-
Save laispace/56185b5dec648bec6edc to your computer and use it in GitHub Desktop.
判断字符是否为中文
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 判断置顶字符是否为中文 | |
* @method isChinese | |
* @param {String} s | |
* @return {Boolean} | |
*/ | |
isChinese: function(s) { | |
//4E00 - 9FA5 | |
var code = ('' + s).charCodeAt(0); | |
if (code >= 0x4E00 && code <= 0x9FA5) { | |
return true; | |
} else { | |
return false; | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment