Skip to content

Instantly share code, notes, and snippets.

@lelinhtinh
Created September 9, 2014 13:57
Show Gist options
  • Save lelinhtinh/c6079d311d00aed2bacf to your computer and use it in GitHub Desktop.
Save lelinhtinh/c6079d311d00aed2bacf to your computer and use it in GitHub Desktop.
Chuyển chuỗi sang mã nhị phân
// 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