Questions tagged [textdecoder]

The TextDecoder interface allows decoding text in various encodings to a JavaScript string.

From MDN: The TextDecoder interface represents a decoder for a specific text encoding, such as UTF-8, ISO-8859-2, KOI8-R, GBK, etc. A decoder takes a stream of bytes as input and emits a stream of code points.

14 questions
6
votes
3 answers

JavaScript: TextDecoder on SharedArrayBuffer

I am facing a problem with decode() on SharedArrayBuffer. Code: var sharedArrayBuffer = new SharedArrayBuffer(2); var uint8Array = new Uint8Array(sharedArrayBuffer); uint8Array[0] = 20; var decoder = new TextDecoder(); …
3
votes
2 answers

Attempted import error: 'TextDecoder' is not exported from '@polkadot/x-textdecoder'

I installed following polkadot packages. "@polkadot/api": "6.10.1", "@polkadot/extension-dapp": "0.41.1", "@polkadot/hw-ledger": "8.2.2", "@polkadot/util-crypto": "8.0.2", When run the "yarn start", I got this…
hobbydev
  • 1,513
  • 19
  • 31
1
vote
0 answers

How to fix the encoding of a string in JavaScript

I have received a broken string from another piece of software. I would have liked to fix its encoding in JavaScript but I feel I am missing something. Here's an exemple of broken string: Détecté àlors ôù And the expected output would be:…
Alexis Delrieu
  • 1,313
  • 2
  • 10
  • 19
1
vote
1 answer

How to know the text encoding scheme so that I can decode the bytes to a string

I'm using Chrome Browser's crypto.SubCrypto API. I generate a PSA-PSS key in it and want to export the key: let key = await window.crypto.subtle.generateKey( { name: "RSA-PSS", modulusLength: 2048, publicExponent: new Uint8Array([0x01,…
Shiqi
  • 837
  • 1
  • 10
  • 18
1
vote
1 answer

Node.js TextDecoder same code but in AWS environment has encoding not supported problem

I use following code for decoding some data const { q } = req.query const { data } = await axios({ url: GOOGLE_AUTOCOMPLETE_ENDPOINT, method: 'get', params: { client: 'chrome', hl: 'ko', gl: 'kr', …
Jaeho Lee
  • 463
  • 1
  • 5
  • 14
1
vote
0 answers

How to convert Javascript Object to ArrayBuffer?

I retrieve an encoded string (using TextEncoder into UTF-8, which was stringified before sending to the server) from the server using AJAX. I parse it upon retrieval and get an Object. I need to convert this Object to a decoded string. TextDecoder…
BReddy
  • 407
  • 3
  • 13
1
vote
1 answer

Is it safe to decode an arbitrary UTF8-byte-chunk to string?

Is it safe to decode an UTF8-string that has been hacked into arbitrary byte-chunks to string (chunk-wise)? Also, what about an arbitrary encoding ? Context is this method: async getFileAsync(fileName: string, encoding: string):string { const…
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
0
votes
1 answer

Null when parsing Uint8Array in Typescript

I have the following object that I get as response when calling aws Lambda client from nodeJS. { '$metadata': { httpStatusCode: 200, requestId: '1245', extendedRequestId: undefined, cfId: undefined, attempts: 1, …
AnOldSoul
  • 4,017
  • 12
  • 57
  • 118
0
votes
0 answers

Javascript decode Uint8Array with id3 metadata

I am trying to get id3 metadata from hls stream. I can convert Uint8Array to string but the response is still not readable to me. Is there a way to get more readable response? var o = new…
Toniq
  • 4,492
  • 12
  • 50
  • 109
0
votes
0 answers

TextDecoder return empty string in JavaScript

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 )…
Babak irannezhad
  • 302
  • 4
  • 19
0
votes
0 answers

Reading excel file fetch API

I am trying to read a excel file and create one locally. I have the below code (async function () { const fetchPromise = fetch(url); let stream = await fetchPromise; let reader = stream.body.getReader(); let decoder = new TextDecoder(); …
opensource-developer
  • 2,826
  • 4
  • 38
  • 88
-1
votes
0 answers

Trouble with decoding octal escape sequences in websocket messages

I am working on a web application that communicates with a PvPGN WebSocket server to receive messages. Messages contain both plain text and octal control sequences representing Unicode characters (for example, \320). The goal is to correctly…
-1
votes
0 answers

TextDecoder not respecting ASCII Label

TextDecoder.decode does not respect the "ascii" label parameter passed to the constructor according to my understanding of it. The example below provides the same values on Chromium and Node 18.17.1. Can someone explain why the TextDecoder is…
jemartin80
  • 498
  • 2
  • 17
-2
votes
1 answer

Are there any models to extract specific data from pdf files?

For the purpose of my project, I am given large pdfs and need to manually extract one specific value (commission). I am looking for ay machine learning or AI model that would be able to automate this process. The structure of the pdfs vary, so…