var str = "A"; var code = str.charCodeAt(); var str2 = String.fromCharCode(code);
文本转二机制,基本示例
1 2 3
var a = "i"; console.log(a.charCodeAt()); //105 console.log(a.charCodeAt().toString(2)); //1101001
1 2 3
var a = "我"; console.log(a.charCodeAt()); //25105 console.log(a.charCodeAt().toString(2)); //110001000010001
1 2 3 4 5
var a = "我们"; console.log(a.length); //2 var list = a.split(""); console.log(list.length); //2<br>console.log(a.charCodeAt().toString(2)); //110001000010001 100111011101100