Questions tagged [uint8array]

The Uint8Array typed array represents an array of 8-bit unsigned integers.

162 questions
2
votes
1 answer

Blob to Uint8Array without callback

Is it possible to convert a Blob to Uint8Array without using a callback and just using JavaScript? How to return the uint8array for the calling variable uint8data? let str='content'; str2blob=(str,type='text/plain')=>new…
Spiderpoison
  • 95
  • 2
  • 9
2
votes
1 answer

convert file to uInt8Array in angular

I want to upload files from angular to postgresql using golang api. In the angular part, I want to convert my file to uInt8Array. I have converted the array, but it is inside something I don't know of (as shown in the image) screenshot-1 So how can…
user14343802
2
votes
0 answers

Returning Uint8Array or Uint16Array from Rust with wasm-bindgen

I want to expose a Rust library function to JavaScript that may return &[u8] or &[u16] depending on some condition. What's the most robust and performant way to do that? I've come up with two possible solutions: Solution 1: Just returning a…
Johannes Ewald
  • 17,665
  • 5
  • 44
  • 39
2
votes
1 answer

Creating a Blob from unicodes (code points) in javascript

I am trying to create a utf-8 encoded html page from a Blob by only specifying unicodes for each character that i want to display within the page. ex: I am trying to display characters 'a' and 'b' with a non breaking space in between. var uint8 =…
2
votes
0 answers

Unable to resolve data for blob

I'm trying to convert a Uint8Array to Blob then read Blob with FileReader but I'm getting the following error: Error: Unable to resolve data for blob: (...blob id) My code looks like following: const segmentation = await…
Ivan QB
  • 43
  • 4
2
votes
1 answer

.NET Core equivalent of Uint8ClampedArray

I'm using jpeg_camera library to get a snapshot from my webapp on my laptop and, by a fetch call, send it to my controller. snapshot.get_image_data returns an object with 3 properties (data: Uint8ClampedArray, width, heigh). When I do the fetch call…
2
votes
0 answers

Problems with TextDecoder decoding Uint8Array

Having problems with TextDecoder decoding Uint8Array. (background info) var staring = "hello"; var array = new Uint8Array(2); array[0]=255; array[1]=0; var binary=(new TextDecoder("utf-8")).decode(array) console.log(binary); Should give me:…
n0sr3v
  • 21
  • 3
2
votes
2 answers

What are the equivalent calls of these JavaScript functions in an AS3 ByteArray?

I'm converting function from JavaScript to AS3 and I'm trying to map the calls between Uint8Array and ByteArray and I notice that a few of the calls are different. var data = new Uint8Array() // Javascript var bytearray = new ByteArray(); //…
1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231
2
votes
2 answers

How to convert UInt16 to UInt8 in Swift 3?

I want to convert UInt16 to UInt8 array, but am getting the following error message: 'init' is unavailable: use 'withMemoryRebound(to:capacity:_)' to temporarily view memory as another layout-compatible type. The code: let statusByte: UInt8…
JTing
  • 651
  • 7
  • 17
2
votes
0 answers

Unable to convert hex string to uint8 byte array

i need to convert hex string to byte array using swift. I have tried with following example hex string "7B737369643A32333A34333A34353A31352C70617373776F72643A31323334357D" This is my code func sendCmd (CMD: [UInt8],length: Int ,hexString: String) …
shamly
  • 21
  • 4
2
votes
2 answers

How can I exchange binary data between Node.js WebSocket server and C# client?

I have Node.js WebSocket server and Unity client with Best HTTP asset. I used to transfer JSON data, but parsing cost too much CPU resources. Now, i try to send byte[] message from C# as follows: //sending sample array - new float[] { 1.32, 3.12…
2
votes
1 answer

Subscript range of [UInt8] - Swift

So the issue I'm having is that I have an object with a argument in the init() that requires an [UInt8]. I want to be able to grab a range from another array and use that in the init. See example. class Test { init(fromArray: [UInt8]) { //…
JoeBayLD
  • 939
  • 2
  • 10
  • 25
1
vote
0 answers

Polkadot.js sr25519 secret key to hex

I am creation a keypair using sr25519PairFromSeed. I am converting the public key from Uint8Array to hex using encodeAddress(publicKey, 0), but i have issues converting the secret key from Uint8array to hex. I use…
1
vote
0 answers

What causes byteOffset to be non-zero with Node fs.readFileSync?

We have some data we're reading with code like: const readData = fs.readFileSync('./dummy') And readData then looks like below, with a byteOffset of 4664 We then need to make a buffer from that existing buffer by doing Buffer.from(readData) to get…
Slbox
  • 10,957
  • 15
  • 54
  • 106
1
vote
2 answers

Construct chess board like texture with Uint8Array

Code: var options = { squareShema: [8,8], pixels: new Uint8Array(8 * 8 * 4) }; options.pixels.fill(122); var I = 0, localCounter = 0; // options.pixels.fill(I ,funny, funny+1); for (var funny = 0; funny < 8*8*4; funny+=4) { if…
Nikola Lukic
  • 4,001
  • 6
  • 44
  • 75
1 2
3
10 11