TextDecoder return empty string in JavaScript

282 Views Asked by At

There is an .stl file with charset us-ascii which must decode as string.

static decodeText( array ) {

    // array is ArrayBuffer
    console.log( array.length ); // 621757404

    return new TextDecoder( ).decode( new Uint8Array( array ) );

}

But return empty string "". It's not occurs for every array. For some .stl file gotten this issue.

How can it be solved ?

Avoiding the `String.fromCharCode.apply(null, array)` shortcut, which
throws a "maximum call stack size exceeded" error for large arrays.
0

There are 0 best solutions below