Skip to content

Commit 9637cc1

Browse files
authored
Update article.md till encoder
1 parent 49b47e3 commit 9637cc1

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

4-binary/02-text-decoder/article.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
# TextDecoder and TextEncoder
1+
# رمزگشای متن و رمزگذار متن
22

3-
What if the binary data is actually a string? For instance, we received a file with textual data.
3+
اگر داده‌ی دودویی ما درواقع یک رشته باشد چه؟ برای نمونه، ما یک فایل با داده‌ی متنی دریافت می‌کنیم.
44

5-
The built-in [TextDecoder](https://encoding.spec.whatwg.org/#interface-textdecoder) object allows one to read the value into an actual JavaScript string, given the buffer and the encoding.
5+
شی رمزگشای متن([TextDecoder](https://encoding.spec.whatwg.org/#interface-textdecoder)) درونی، به یک نفر اجازه می‌دهد که با توجه به بافر و رمزگذاری داده شده، مقدار را در یک رشته‌ی واقعی جاوااسکریپت بخواند.
66

7-
We first need to create it:
7+
ابتدا ما نیاز به ساخت آن داریم:
88
```js
99
let decoder = new TextDecoder([label], [options]);
1010
```
1111

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`.
15-
- **`ignoreBOM`** -- boolean, if `true` then ignore BOM (an optional byte-order Unicode mark), rarely needed.
12+
- **`label`** -- و برخی دیگر از رمزگذارای‌ها نیز پشتیبانی می‌شوند `windows-1251` و `big5` است اما `utf-8` رمزگذاری، به طور پیش فرض
13+
- **`options`** -- :شی اختیاری
14+
- **`fatal`** -- جایگذاری می‌کند `\uFFFD` برای کاراکتر غیرقابل قبول (غیرقابل رمزگشایی) پرتاب می‌شود. در غیر این صورت (که حالت پیش‌فرض می‌باشد)، آن‌ها را با کاراکتر (exception)باشد، یک استثنا `true` اگر مقدار آن .boolean از جنس
15+
- **`ignoreBOM`** -- اختیاری مرتب شده برحسب بایت) که به ندرت به آن نیاز پیدا می‌شود را نادیده می‌گیرد unicode یک علامت)BOM ،باشد `true` اگر مقدار آن .boolean از جنس
1616

17-
...And then decode:
17+
...و سپس رمزگشایی کنید:
1818

1919
```js
2020
let str = decoder.decode([input], [options]);
2121
```
2222

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`)منبع
24+
- **`options`** -- :شی اختیاری
25+
- **`stream`** -- ها، هنگامی که رمزگشا برای مقادیر قابل توجه داده‌ها مکررا فراخوانی می‌شود، درست است. در این مورد، ممکن است یک کاراکتر چند بایتی، برخی مواقع بین بخش‌هایی از داده‌ها تقسیم شود. این امکان به رمزگشای متن می‌گوید که کاراکترهای "ناتمام" را به خاطر داشته باشد و هنگامی که بخش بعدی داده وارد شد، آن‌ها را رمزگشایی کندstream برای رمزگشایی
2626

27-
For instance:
27+
برای نمونه:
2828

2929
```js run
3030
let uint8Array = new Uint8Array([72, 101, 108, 108, 111]);
@@ -39,14 +39,14 @@ let uint8Array = new Uint8Array([228, 189, 160, 229, 165, 189]);
3939
alert( new TextDecoder().decode(uint8Array) ); // 你好
4040
```
4141

42-
We can decode a part of the buffer by creating a subarray view for it:
42+
ما می‌توانیم بخشی از یک بافر را با ساخت یک view زیرآرایه برای آن، رمزگشایی کنیم:
4343

4444

4545
```js run
4646
let uint8Array = new Uint8Array([0, 72, 101, 108, 108, 111, 0]);
4747

48-
// the string is in the middle
49-
// create a new view over it, without copying anything
48+
// رشته در وسط می‌باشد
49+
// جدید روی آن، بدون کپی کردن چیزی view ساخت یک
5050
let binaryString = uint8Array.subarray(1, -1);
5151

5252
alert( new TextDecoder().decode(binaryString) ); // Hello

0 commit comments

Comments
 (0)