Created
June 27, 2013 17:44
-
-
Save felipemorais/5878637 to your computer and use it in GitHub Desktop.
Javascript get string size. i.e. Cookie size
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 getByteSize(s) { | |
return encodeURIComponent('<q></q>' + s).length; | |
} | |
getByteSize(document.cookie); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'<q></q>' + s
Why the quotes tag ?