Created
June 13, 2014 09:26
-
-
Save fakefish/b6360550ebe2c4b43021 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
function byteLen(target) { | |
var byteLength = target.length, i = 0; | |
for (; i < target.length; i++) { | |
if (target.charCodeAt(i) > 255) { | |
byteLength++; | |
} | |
} | |
return byteLength; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment