Created
September 9, 2014 13:57
-
-
Save lelinhtinh/c6079d311d00aed2bacf to your computer and use it in GitHub Desktop.
Chuyển chuỗi sang mã nhị phân
This file contains hidden or 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
// http://www.midnight-coding.com/2014/05/convert-string-to-binary-to-string.html | |
function stringToBinary(stringValue) { | |
return stringValue.replace(/.{1}/g, function (matchedString) { | |
var binString = matchedString.charCodeAt(0).toString(2); | |
return '00000000'.substring(0, 8 - binString.length) + binString; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment