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
What if the binary data is actually a string? For instance, we received a file with textual data.
3
+
¿Qué pasa si los datos binarios son en realidad un string? Por ejemplo, recibimos un archivo con datos textuales.
4
4
5
-
The build-in[TextDecoder](https://encoding.spec.whatwg.org/#interface-textdecoder)object allows to read the value into an actual JavaScript string, given the buffer and the encoding.
5
+
El objeto[TextDecoder](https://encoding.spec.whatwg.org/#interface-textdecoder)nos permite leer el texto de un conjunto de datos binarios y convertirlo en un dato de tipo string de JavaScript, dados el búfer y la codificación.
6
6
7
-
We first need to create it:
7
+
Primero necesitamos crearlo:
8
8
```js
9
9
let decoder =newTextDecoder([label], [options]);
10
10
```
11
11
12
-
-**`label`** -- the encoding, `utf-8`by default, but`big5`, `windows-1251`and many other are also supported.
13
-
-**`options`** -- optional object:
14
-
-**`fatal`** -- boolean, if `true`then throw an exception for invalid (non-decodable) characters, otherwise (default) replace them with character`\uFFFD`.
-**`label`** -- la codificación, `utf-8`por defecto, pero`big5`, `windows-1251`y muchos otros también son soportados.
13
+
-**`options`** -- objeto opcional:
14
+
-**`fatal`** -- booleano, si es `true`arroja una excepción por caracteres inválidos (no-decodificable), de otra manera (por defecto) son reemplazados con el carácter`\uFFFD`.
15
+
-**`ignoreBOM`** -- booleano, si es `true`entonces ignora BOM (una marca Unicode de orden de bytes opcional), raramente es necesario.
16
16
17
-
...And then decode:
17
+
...Y luego decodificar:
18
18
19
19
```js
20
20
let str =decoder.decode([input], [options]);
21
21
```
22
22
23
-
-**`input`** -- `BufferSource`to decode.
24
-
-**`options`** -- optional object:
25
-
-**`stream`** -- true for decoding streams, when `decoder`is called repeatedly with incoming chunks of data. In that case a multi-byte character may occasionally split between chunks. This options tells `TextDecoder`to memorize "unfinished" characters and decode them when the next chunk comes.
23
+
-**`input`** -- `BufferSource`para decodificar.
24
+
-**`options`** -- objeto opcional:
25
+
-**`stream`** -- true para decodificación de secuencias, cuando el `decoder`es usado repetidamente para fragmentos de datos entrantes. En ese caso, un carácter de varios bytes puede ocasionalmente dividirse entre fragmentos. Esta opción le dice al `TextDecoder`que memorice caracteres "incompletos" y que los decodifique cuando venga el siguiente fragmento.
26
26
27
-
For instance:
27
+
Por ejemplo:
28
28
29
29
```js run
30
-
let uint8Array =newUint8Array([72, 101, 108, 108, 111]);
30
+
let uint8Array =newUint8Array([72, 111, 108, 97]);
0 commit comments