You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug fix] Support for to_string calls with big Uint8Arrays #57
/*The main idea is to split the buffer into a smaller buffers,call to_string on each one of them, and concatenate the results*/vartoStringChunkSize=32767;functionto_string(bytes){if(typeofTextDecoder==="function"){returnnewTextDecoder("utf-8",{fatal: true}).decode(bytes);}varnumChunks=Math.ceil(bytes.length/toStringChunkSize);if(numChunks>1){vartotalString='';for(vari=0;i<numChunks;i++){totalString+=to_string(Array.prototype.slice.call(bytes,i*toStringChunkSize,(i+1)*toStringChunkSize));}returntotalString;}try{returndecodeURIComponent(escape(String.fromCharCode.apply(null,bytes)));}catch(_){thrownewTypeError("The encoded data was not valid.");}}
Activity
jedisct1 commentedon May 29, 2016
Unfortunately, the bytes cannot be split at arbitrary positions, because the split could then happen in the middle of a UTF-8 sequence :(