研究了一下,成果如下:
string --> binary array
Array.prototype.map.call( __YOUR_STRING__ , function( c ) { return c.charCodeAt(0); } );
binary array --> string
String.fromCharCode.apply( null , __YOUR_BINARY_ARRAY__ );
本文介绍了一种将字符串转换为二进制数组的方法,同时也提供了从二进制数组还原字符串的技术。通过使用JavaScript的Array.prototype.map和String.fromCharCode等函数实现数据格式之间的相互转换。
研究了一下,成果如下:
string --> binary array
Array.prototype.map.call( __YOUR_STRING__ , function( c ) { return c.charCodeAt(0); } );
binary array --> string
String.fromCharCode.apply( null , __YOUR_BINARY_ARRAY__ );
4650
988
2113

被折叠的 条评论
为什么被折叠?