Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to convert uint8array in javascript into a normal array or string?
How to convert uint8array in javascript into a normal array or string?
A Uint8Array object, a typed array of 8-bit unsigned integer values. The content will be initialized to 0. If the requested number of bytes cannot be allocated, an exception will be thrown.

Method of converting into ordinary array:

1, structure

uint 8 array = new uint 8 array(length);

2. Conversion method:

( 1)var array = array . from(uint 8 array)

(2)var array =[]. slice . call(uint 8 array)

Precautions:

//When //js writes data to ble, the data type is arraybuffer. After Uint8Array sets the data, if you use,

Array method, be careful. //The memory after Uint8Array.buffer returned by the subarray is the memory before the subarray.

Save. //If you want to transmit new data, you'd better open up new memory to avoid the problems caused by the difference between what you see and what you measure.