erCode(str) {
let result = [];
let list = str.split("");
for (var i = 0; i < list.length; i++) {
if (i != 0) {
result.push(" "); // Separate each item with a space (except the first item)
}
let item = list[i];
let binaryStr = item.charCodeAt().toString(2); //Binary conversion
result.push(binaryStr);
}
return result.join(""); //Convert the spliced binary array into a string
},
js converts string data to binary
Guess you like
Origin blog.csdn.net/weixin_44191318/article/details/130987100
Recommended
Ranking