Created
          March 3, 2016 04:43 
        
      - 
      
- 
        Save skratchdot/e095036fad80597f1c1a to your computer and use it in GitHub Desktop. 
Revisions
- 
        skratchdot created this gist Mar 3, 2016 .There are no files selected for viewingThis 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ // source: http://stackoverflow.com/a/11058858 function ab2str(buf) { return String.fromCharCode.apply(null, new Uint16Array(buf)); } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ // source: http://stackoverflow.com/a/11058858 function str2ab(str) { var buf = new ArrayBuffer(str.length * 2); // 2 bytes for each char var bufView = new Uint16Array(buf); for (var i = 0, strLen = str.length; i < strLen; i++) { bufView[i] = str.charCodeAt(i); } return buf; }