-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathunicode.po
More file actions
794 lines (649 loc) · 81.1 KB
/
Copy pathunicode.po
File metadata and controls
794 lines (649 loc) · 81.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Danial Behzadi <dani.behzi@ubuntu.com>, 2025
# Rafael Fontenelle <rffontenelle@gmail.com>, 2025
# Revisto <theRevisto@gmail.com>, 2025
# Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.14\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-09-16 12:56+0000\n"
"PO-Revision-Date: 2026-09-13 19:15+0330\n"
"Last-Translator: Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026\n"
"Language-Team: Persian (https://github.com/python/python-docs-fa/)\n"
"Language: fa\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 3.6\n"
msgid "Unicode HOWTO"
msgstr "راهنمای عملی یونیکد"
msgid "Release"
msgstr "انتشار"
msgid "1.12"
msgstr "1.12"
msgid "This HOWTO discusses Python's support for the Unicode specification for representing textual data, and explains various problems that people commonly encounter when trying to work with Unicode."
msgstr "این راهنمای عملی پشتیبانی پایتون از مشخصات یونیکد برای بازنمایی دادههای متنی را بررسی میکند و مشکلات مختلفی را توضیح میدهد که افراد معمولاً هنگام تلاش برای کار با یونیکد با آنها مواجه میشوند."
msgid "Introduction to Unicode"
msgstr "مقدمهای بر یونیکد"
msgid "Definitions"
msgstr "تعاریف"
msgid "Today's programs need to be able to handle a wide variety of characters. Applications are often internationalized to display messages and output in a variety of user-selectable languages; the same program might need to output an error message in English, French, Japanese, Hebrew, or Russian. Web content can be written in any of these languages and can also include a variety of emoji symbols. Python's string type uses the Unicode Standard for representing characters, which lets Python programs work with all these different possible characters."
msgstr "برنامههای امروزی باید بتوانند تنوع گستردهای از نویسهها را مدیریت کنند. برنامههای کاربردی اغلب بینالمللیسازی میشوند تا پیامها و خروجیها را به زبانهای مختلف قابل انتخاب توسط کاربر نمایش دهند؛ ممکن است همان برنامه نیاز داشته باشد پیام خطایی را به انگلیسی، فرانسوی، ژاپنی، عبری یا روسی نمایش دهد. محتوای وب میتواند به هر یک از این زبانها نوشته شود و همچنین میتواند شامل انواع نمادهای ایموجی باشد. نوع رشته پایتون از استاندارد یونیکد برای نمایش نویسهها استفاده میکند، که به برنامههای پایتون امکان میدهد با تمام این نویسههای ممکن متفاوت کار کنند."
msgid "Unicode (https://www.unicode.org/) is a specification that aims to list every character used by human languages and give each character its own unique code. The Unicode specifications are continually revised and updated to add new languages and symbols."
msgstr "یونیکد (https://www.unicode.org/) مشخصاتی است که هدف آن فهرست کردن تمام نویسههای مورد استفاده در زبانهای انسانی و اختصاص یک کد یکتا به هر نویسه است. مشخصات یونیکد بهطور مداوم برای افزودن زبانها و نمادهای جدید بازنگری و بهروزرسانی میشود."
msgid "A **character** is the smallest possible component of a text. 'A', 'B', 'C', etc., are all different characters. So are 'È' and 'Í'. Characters vary depending on the language or context you're talking about. For example, there's a character for \"Roman Numeral One\", 'Ⅰ', that's separate from the uppercase letter 'I'. They'll usually look the same, but these are two different characters that have different meanings."
msgstr "**نویسه** کوچکترین کامپوننت ممکن یک متن است. 'A'، 'B'، 'C' و غیره، همگی نویسههای متفاوتی هستند. 'È' و 'Í' نیز همینطور هستند. نویسهها بسته به زبان یا زمینهای که در مورد آن صحبت میکنید، متفاوت هستند. برای مثال، نویسهای برای «عدد رومی یک»، 'Ⅰ'، وجود دارد که از حرف بزرگ 'I' جدا است. این دو معمولاً یکسان به نظر میرسند، اما اینها دو نویسه متفاوت هستند که معانی متفاوتی دارند."
msgid "The Unicode standard describes how characters are represented by **code points**. A code point value is an integer in the range 0 to 0x10FFFF (about 1.1 million values, the `actual number assigned <https://www.unicode.org/versions/latest/#Summary>`_ is less than that). In the standard and in this document, a code point is written using the notation ``U+265E`` to mean the character with value ``0x265e`` (9,822 in decimal)."
msgstr "استاندارد یونیکد توصیف میکند که نویسهها چگونه با **نقاط کد (code points)** نشان داده میشوند. مقدار یک نقطه کد، یک عدد صحیح در بازهی ۰ تا 0x10FFFF است (حدود ۱٫۱ میلیون مقدار، `تعداد واقعی اختصاصدادهشده <https://www.unicode.org/versions/latest/#Summary>`_ کمتر از آن است). در استاندارد و در این سند، یک نقطه کد با استفاده از نماد ``U+265E`` نوشته میشود که به معنای نویسهای با مقدار ``0x265e`` (۹٬۸۲۲ در مبنای ده) است."
msgid "The Unicode standard contains a lot of tables listing characters and their corresponding code points:"
msgstr "استاندارد یونیکد شامل جدولهای بسیاری است که نویسهها و نقاط کد متناظر آنها را فهرست میکنند:"
msgid ""
"0061 'a'; LATIN SMALL LETTER A\n"
"0062 'b'; LATIN SMALL LETTER B\n"
"0063 'c'; LATIN SMALL LETTER C\n"
"...\n"
"007B '{'; LEFT CURLY BRACKET\n"
"...\n"
"2167 'Ⅷ'; ROMAN NUMERAL EIGHT\n"
"2168 'Ⅸ'; ROMAN NUMERAL NINE\n"
"...\n"
"265E '♞'; BLACK CHESS KNIGHT\n"
"265F '♟'; BLACK CHESS PAWN\n"
"...\n"
"1F600 '😀'; GRINNING FACE\n"
"1F609 '😉'; WINKING FACE\n"
"..."
msgstr ""
"0061 'a'; LATIN SMALL LETTER A\n"
"0062 'b'; LATIN SMALL LETTER B\n"
"0063 'c'; LATIN SMALL LETTER C\n"
"...\n"
"007B '{'; LEFT CURLY BRACKET\n"
"...\n"
"2167 'Ⅷ'; ROMAN NUMERAL EIGHT\n"
"2168 'Ⅸ'; ROMAN NUMERAL NINE\n"
"...\n"
"265E '♞'; BLACK CHESS KNIGHT\n"
"265F '♟'; BLACK CHESS PAWN\n"
"...\n"
"1F600 '😀'; GRINNING FACE\n"
"1F609 '😉'; WINKING FACE\n"
"..."
msgid "Strictly, these definitions imply that it's meaningless to say 'this is character ``U+265E``'. ``U+265E`` is a code point, which represents some particular character; in this case, it represents the character 'BLACK CHESS KNIGHT', '♞'. In informal contexts, this distinction between code points and characters will sometimes be forgotten."
msgstr "بهطور دقیق، این تعاریف ایجاب میکنند که گفتن «این نویسه ``U+265E`` است» بیمعنا باشد. ``U+265E`` یک نقطه کد (code point) است که نمایانگر نویسهای خاص است؛ در این مورد، نمایانگر نویسهی «BLACK CHESS KNIGHT»، «♞» است. در بافتهای غیررسمی، گاهی این تمایز میان نقاط کد و نویسهها فراموش میشود."
msgid "A character is represented on a screen or on paper by a set of graphical elements that's called a **glyph**. The glyph for an uppercase A, for example, is two diagonal strokes and a horizontal stroke, though the exact details will depend on the font being used. Most Python code doesn't need to worry about glyphs; figuring out the correct glyph to display is generally the job of a GUI toolkit or a terminal's font renderer."
msgstr "یک نویسه روی نمایشگر یا روی کاغذ با مجموعهای از عناصر گرافیکی نمایش داده میشود که به آن **گلیف** (glyph) میگویند. برای مثال، گلیف یک نویسهی A بزرگ از دو خط مورب و یک خط افقی تشکیل شده است، اگرچه جزئیات دقیق به قلم استفادهشده بستگی دارد. در بیشتر کدهای Python، نیازی به نگرانی درباره گلیفها نیست؛ تعیین گلیف صحیح برای نمایش معمولاً وظیفهی یک جعبهابزار GUI یا رندرکنندهی قلم پایانه است."
msgid "Encodings"
msgstr "کدگذاریها"
msgid "To summarize the previous section: a Unicode string is a sequence of code points, which are numbers from 0 through ``0x10FFFF`` (1,114,111 decimal). This sequence of code points needs to be represented in memory as a set of **code units**, and **code units** are then mapped to 8-bit bytes. The rules for translating a Unicode string into a sequence of bytes are called a **character encoding**, or just an **encoding**."
msgstr "برای جمعبندی بخش پیشین: یک رشتهی یونیکد، دنبالهای از نقاط کد است که اعدادی از ۰ تا ``0x10FFFF`` (۱٬۱۱۴٬۱۱۱ در مبنای ده) هستند. این دنباله از نقاط کد باید در حافظه بهصورت مجموعهای از **واحدهای کد** بازنمایی شود، و سپس **واحدهای کد** به بایتهای ۸ بیتی نگاشت میشوند. قواعد تبدیل یک رشتهی یونیکد به دنبالهای از بایتها، **کدگذاری نویسه** یا صرفاً یک **کدگذاری** نامیده میشوند."
msgid "The first encoding you might think of is using 32-bit integers as the code unit, and then using the CPU's representation of 32-bit integers. In this representation, the string \"Python\" might look like this:"
msgstr "اولین کدگذاری که ممکن است به آن فکر کنید، استفاده از اعداد صحیح ۳۲ بیتی بهعنوان واحد کد (code unit) و سپس استفاده از بازنمایی CPU از اعداد صحیح ۳۲ بیتی است. در این بازنمایی، رشتهی \"Python\" ممکن است به این شکل باشد:"
msgid ""
" P y t h o n\n"
"0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00\n"
" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23"
msgstr ""
" P y t h o n\n"
"0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00\n"
" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23"
msgid "This representation is straightforward but using it presents a number of problems."
msgstr "این بازنمایی ساده است، اما استفاده از آن تعدادی مشکل ایجاد میکند."
msgid "It's not portable; different processors order the bytes differently."
msgstr "قابلحمل نیست؛ پردازندههای مختلف، بایتها را به ترتیب متفاوتی مرتب میکنند."
msgid "It's very wasteful of space. In most texts, the majority of the code points are less than 127, or less than 255, so a lot of space is occupied by ``0x00`` bytes. The above string takes 24 bytes compared to the 6 bytes needed for an ASCII representation. Increased RAM usage doesn't matter too much (desktop computers have gigabytes of RAM, and strings aren't usually that large), but expanding our usage of disk and network bandwidth by a factor of 4 is intolerable."
msgstr "این روش بسیار اتلافکنندهی فضا است. در بیشتر متنها، بیشتر نقاط کد (code points) کمتر از ۱۲۷ یا کمتر از ۲۵۵ هستند، بنابراین فضای زیادی توسط بایتهای ``0x00`` اشغال میشود. رشتهی بالا در مقایسه با ۶ بایت مورد نیاز برای نمایش ASCII، ۲۴ بایت فضا اشغال میکند. افزایش مصرف RAM اهمیت چندانی ندارد (رایانههای رومیزی گیگابایتها RAM دارند و رشتهها معمولاً آنقدر بزرگ نیستند)، اما افزایش استفادهی ما از پهنای باند دیسک و شبکه با ضریب ۴ تحملناپذیر است."
msgid "It's not compatible with existing C functions such as ``strlen()``, so a new family of wide string functions would need to be used."
msgstr "این با توابع موجود C مانند ``strlen()`` سازگار نیست، بنابراین باید از خانوادهی جدیدی از توابع رشتهی پهن (wide string) استفاده شود."
msgid "Therefore this encoding isn't used very much, and people instead choose other encodings that are more efficient and convenient, such as UTF-8."
msgstr "بنابراین این کدگذاری چندان استفاده نمیشود و در عوض، افراد کدگذاریهای دیگری را انتخاب میکنند که کارآمدتر و مناسبتر هستند، مانند UTF-8."
msgid "UTF-8 is one of the most commonly used encodings, and Python often defaults to using it. UTF stands for \"Unicode Transformation Format\", and the '8' means that 8-bit values are used in the encoding. (There are also UTF-16 and UTF-32 encodings, but they are less frequently used than UTF-8.) UTF-8 uses the following rules:"
msgstr "UTF-8 یکی از پرکاربردترین کدگذاریها است و پایتون اغلب بهطور پیشفرض از آن استفاده میکند. UTF مخفف «Unicode Transformation Format» است و «8» به این معناست که در این کدگذاری از مقادیر ۸ بیتی استفاده میشود. (کدگذاریهای UTF-16 و UTF-32 نیز وجود دارند، اما کمتر از UTF-8 استفاده میشوند.) UTF-8 از قواعد زیر پیروی میکند:"
msgid "If the code point is < 128, it's represented by the corresponding byte value."
msgstr "اگر نقطهکد کمتر از ۱۲۸ باشد، با مقدار بایت متناظر بازنمایی میشود."
msgid "If the code point is >= 128, it's turned into a sequence of two, three, or four bytes, where each byte of the sequence is between 128 and 255."
msgstr "اگر نقطهکد بزرگتر یا مساوی ۱۲۸ باشد، به دنبالهای از دو، سه یا چهار بایت تبدیل میشود، که در آن هر بایتِ دنباله بین ۱۲۸ و ۲۵۵ است."
msgid "UTF-8 has several convenient properties:"
msgstr "UTF-8 دارای چندین ویژگی مناسب است:"
msgid "It can handle any Unicode code point."
msgstr "میتواند هر نقطهکد یونیکد را پردازش کند."
msgid "A Unicode string is turned into a sequence of bytes that contains embedded zero bytes only where they represent the null character (U+0000). This means that UTF-8 strings can be processed by C functions such as ``strcpy()`` and sent through protocols that can't handle zero bytes for anything other than end-of-string markers."
msgstr "یک رشته یونیکدی به دنبالهای از بایتها تبدیل میشود که فقط در جاهایی حاوی بایتهای صفر تعبیهشده است که این بایتها نمایانگر نویسه تهی (U+0000) باشند. این بدان معناست که رشتههای UTF-8 میتوانند توسط توابع C مانند ``strcpy()`` پردازش شوند و از طریق پروتکلهایی که نمیتوانند بایتهای صفر را برای هیچ منظوری بهجز نشانگرهای پایان رشته مدیریت کنند، ارسال شوند."
msgid "A string of ASCII text is also valid UTF-8 text."
msgstr "یک رشته از متن ASCII، یک متن UTF-8 معتبر نیز هست."
msgid "UTF-8 is fairly compact; the majority of commonly used characters can be represented with one or two bytes."
msgstr "UTF-8 نسبتاً فشرده است؛ بیشتر نویسههای پرکاربرد را میتوان با یک یا دو بایت نمایش داد."
msgid "If bytes are corrupted or lost, it's possible to determine the start of the next UTF-8-encoded code point and resynchronize. It's also unlikely that random 8-bit data will look like valid UTF-8."
msgstr "اگر بایتها خراب یا از دست رفته باشند، میتوان آغاز نقطه کد بعدیِ کدگذاریشده با UTF-8 را تعیین کرد و همگامسازی مجدد انجام داد. همچنین بعید است که دادههای تصادفی ۸ بیتی شبیه UTF-8 معتبر به نظر برسند."
msgid "UTF-8 is a byte oriented encoding. The encoding specifies that each character is represented by a specific sequence of one or more bytes. This avoids the byte-ordering issues that can occur with integer and word oriented encodings, like UTF-16 and UTF-32, where the sequence of bytes varies depending on the hardware on which the string was encoded."
msgstr "UTF-8 یک کدگذاری بایتمحور است. این کدگذاری مشخص میکند که هر نویسه با دنبالهای مشخص از یک یا چند بایت نمایش داده میشود. این امر از مسائل ترتیب بایتها که ممکن است در کدگذاریهای عدد صحیحمحور و کلمهمحور، مانند UTF-16 و UTF-32، رخ دهد، جلوگیری میکند؛ در این کدگذاریها، دنبالهی بایتها بسته به سختافزاری که رشته روی آن کدگذاری شده است، متفاوت است."
msgid "References"
msgstr "ارجاعها"
msgid "The `Unicode Consortium site <https://www.unicode.org>`_ has character charts, a glossary, and PDF versions of the Unicode specification. Be prepared for some difficult reading. `A chronology <https://www.unicode.org/history/>`_ of the origin and development of Unicode is also available on the site."
msgstr "`وبسایت کنسرسیوم یونیکد <https://www.unicode.org>`_ دارای جدولهای نویسهها، واژهنامه و نسخههای PDF از مشخصات یونیکد است. برای مطالعهای دشوار آماده باشید. `گاهشماری <https://www.unicode.org/history/>`_ از پیدایش و گسترش یونیکد نیز در این وبسایت در دسترس است."
msgid "On the Computerphile Youtube channel, Tom Scott briefly `discusses the history of Unicode and UTF-8 <https://www.youtube.com/watch?v=MijmeoH9LT4>`_ (9 minutes 36 seconds)."
msgstr "در کانال یوتیوب Computerphile، تام اسکات `تاریخچهی یونیکد و UTF-8 را بهاختصار بررسی میکند <https://www.youtube.com/watch?v=MijmeoH9LT4>`_ (۹ دقیقه و ۳۶ ثانیه)."
msgid "To help understand the standard, Jukka Korpela has written `an introductory guide <https://jkorpela.fi/unicode/guide.html>`_ to reading the Unicode character tables."
msgstr "برای کمک به درک این استاندارد، Jukka Korpela یک `راهنمای مقدماتی <https://jkorpela.fi/unicode/guide.html>`_ برای خواندن جدولهای نویسههای یونیکد نوشته است."
msgid "Another `good introductory article <https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/>`_ was written by Joel Spolsky. If this introduction didn't make things clear to you, you should try reading this alternate article before continuing."
msgstr "یک `مقالهی مقدماتی خوب <https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/>`_ دیگر توسط Joel Spolsky نوشته شده است. اگر این مقدمه مطالب را برای شما روشن نکرد، باید سعی کنید پیش از ادامه، این مقالهی جایگزین را بخوانید."
msgid "Wikipedia entries are often helpful; see the entries for \"`character encoding <https://en.wikipedia.org/wiki/Character_encoding>`_\" and `UTF-8 <https://en.wikipedia.org/wiki/UTF-8>`_, for example."
msgstr "مقالههای ویکیپدیا اغلب مفید هستند؛ برای مثال، مقالههای «`کدگذاری نویسه <https://fa.wikipedia.org/wiki/کدبندی_نویسه>`_» و `UTF-8 <https://fa.wikipedia.org/wiki/یوتیاف-۸>`_ را ببینید."
msgid "Python's Unicode Support"
msgstr "پشتیبانی پایتون از یونیکد"
msgid "Now that you've learned the rudiments of Unicode, we can look at Python's Unicode features."
msgstr "اکنون که مبانی یونیکد را آموختهاید، میتوانیم ویژگیهای یونیکد پایتون را بررسی کنیم."
msgid "The String Type"
msgstr "نوع رشته"
msgid "Since Python 3.0, the language's :class:`str` type contains Unicode characters, meaning any string created using ``\"unicode rocks!\"``, ``'unicode rocks!'``, or the triple-quoted string syntax is stored as Unicode."
msgstr "از پایتون 3.0، نوع :class:`str` این زبان شامل نویسههای یونیکد است، به این معنا که هر رشتهای که با استفاده از ``\"unicode rocks!\"``، ``'unicode rocks!'`` یا سینتکس رشتههای سهنقلقولی ایجاد شود، بهصورت یونیکد ذخیره میشود."
msgid "The default encoding for Python source code is UTF-8, so you can simply include a Unicode character in a string literal::"
msgstr "کدگذاری پیشفرض برای کد منبع پایتون UTF-8 است، بنابراین میتوانید بهسادگی یک نویسهی یونیکد را در یک رشتهی لفظی (string literal) قرار دهید::"
msgid ""
"try:\n"
" with open('/tmp/input.txt', 'r') as f:\n"
" ...\n"
"except OSError:\n"
" # 'File not found' error message.\n"
" print(\"Fichier non trouvé\")"
msgstr ""
"try:\n"
" with open('/tmp/input.txt', 'r') as f:\n"
" ...\n"
"except OSError:\n"
" # 'File not found' error message.\n"
" print(\"Fichier non trouvé\")"
msgid "Side note: Python 3 also supports using Unicode characters in identifiers::"
msgstr "نکته جانبی: پایتون 3 همچنین از نویسههای یونیکد در شناسهها پشتیبانی میکند::"
msgid ""
"répertoire = \"/tmp/records.log\"\n"
"with open(répertoire, \"w\") as f:\n"
" f.write(\"test\\n\")"
msgstr ""
"répertoire = \"/tmp/records.log\"\n"
"with open(répertoire, \"w\") as f:\n"
" f.write(\"test\\n\")"
msgid "If you can't enter a particular character in your editor or want to keep the source code ASCII-only for some reason, you can also use escape sequences in string literals. (Depending on your system, you may see the actual capital-delta glyph instead of a \\u escape.) ::"
msgstr "اگر نمیتوانید نویسه خاصی را در ویرایشگر خود وارد کنید یا به هر دلیلی میخواهید کد منبع فقط ASCII باقی بماند، میتوانید از دنبالههای خنثیسازی در رشتهنوشتهها استفاده کنید. (بسته به سامانه شما، ممکن است به جای یک دنباله خنثیسازی \\u، نگاشتک واقعی دلتای بزرگ را ببینید.) ::"
msgid ""
">>> \"\\N{GREEK CAPITAL LETTER DELTA}\" # Using the character name\n"
"'\\u0394'\n"
">>> \"\\u0394\" # Using a 16-bit hex value\n"
"'\\u0394'\n"
">>> \"\\U00000394\" # Using a 32-bit hex value\n"
"'\\u0394'"
msgstr ""
">>> \"\\N{GREEK CAPITAL LETTER DELTA}\" # Using the character name\n"
"'\\u0394'\n"
">>> \"\\u0394\" # Using a 16-bit hex value\n"
"'\\u0394'\n"
">>> \"\\U00000394\" # Using a 32-bit hex value\n"
"'\\u0394'"
msgid "In addition, one can create a string using the :func:`~bytes.decode` method of :class:`bytes`. This method takes an *encoding* argument, such as ``UTF-8``, and optionally an *errors* argument."
msgstr "علاوه بر این، میتوانید با استفاده از متد :func:`~bytes.decode` کلاس :class:`bytes` یک رشته ایجاد کنید. این متد یک آرگومان *encoding*، مانند ``UTF-8``، و بهاختیار یک آرگومان *errors* میگیرد."
msgid "The *errors* argument specifies the response when the input string can't be converted according to the encoding's rules. Legal values for this argument are ``'strict'`` (raise a :exc:`UnicodeDecodeError` exception), ``'replace'`` (use ``U+FFFD``, ``REPLACEMENT CHARACTER``), ``'ignore'`` (just leave the character out of the Unicode result), or ``'backslashreplace'`` (inserts a ``\\xNN`` escape sequence). The following examples show the differences::"
msgstr "آرگومان *errors* پاسخ را زمانی که رشته ورودی نمیتواند بر اساس قواعد کدگذاری تبدیل شود، مشخص میکند. مقادیر مجاز برای این آرگومان عبارتاند از ``'strict'`` (پرتاب استثنای :exc:`UnicodeDecodeError`)، ``'replace'`` (استفاده از ``U+FFFD``، ``REPLACEMENT CHARACTER``)، ``'ignore'`` (فقط نویسه را از نتیجهی یونیکد حذف میکند)، یا ``'backslashreplace'`` (یک دنبالهی خنثیسازی ``\\xNN`` درج میکند). مثالهای زیر تفاوتها را نشان میدهند::"
msgid ""
">>> b'\\x80abc'.decode(\"utf-8\", \"strict\")\n"
"Traceback (most recent call last):\n"
" ...\n"
"UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0:\n"
" invalid start byte\n"
">>> b'\\x80abc'.decode(\"utf-8\", \"replace\")\n"
"'\\ufffdabc'\n"
">>> b'\\x80abc'.decode(\"utf-8\", \"backslashreplace\")\n"
"'\\\\x80abc'\n"
">>> b'\\x80abc'.decode(\"utf-8\", \"ignore\")\n"
"'abc'"
msgstr ""
">>> b'\\x80abc'.decode(\"utf-8\", \"strict\")\n"
"Traceback (most recent call last):\n"
" ...\n"
"UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0:\n"
" invalid start byte\n"
">>> b'\\x80abc'.decode(\"utf-8\", \"replace\")\n"
"'\\ufffdabc'\n"
">>> b'\\x80abc'.decode(\"utf-8\", \"backslashreplace\")\n"
"'\\\\x80abc'\n"
">>> b'\\x80abc'.decode(\"utf-8\", \"ignore\")\n"
"'abc'"
msgid "Encodings are specified as strings containing the encoding's name. Python comes with roughly 100 different encodings; see the Python Library Reference at :ref:`standard-encodings` for a list. Some encodings have multiple names; for example, ``'latin-1'``, ``'iso_8859_1'`` and ``'8859``' are all synonyms for the same encoding."
msgstr "کدگذاریها بهصورت رشتههایی شامل نام کدگذاری مشخص میشوند. پایتون دارای حدود ۱۰۰ کدگذاری مختلف است؛ برای دیدن فهرست آنها به مرجع کتابخانه پایتون در :ref:`standard-encodings` مراجعه کنید. برخی کدگذاریها چندین نام دارند؛ برای مثال، ``'latin-1'``، ``'iso_8859_1'`` و ``'8859``' همه نامهای مترادف برای یک کدگذاری هستند."
msgid "One-character Unicode strings can also be created with the :func:`chr` built-in function, which takes integers and returns a Unicode string of length 1 that contains the corresponding code point. The reverse operation is the built-in :func:`ord` function that takes a one-character Unicode string and returns the code point value::"
msgstr "رشتههای یونیکد تکنویسهای را همچنین میتوان با تابع توکار :func:`chr` ایجاد کرد، که اعداد صحیح را میگیرد و رشتهای یونیکد به طول ۱ برمیگرداند که حاوی نقطه کد متناظر است. عملیات معکوس، تابع توکار :func:`ord` است که یک رشته یونیکد تکنویسهای را میگیرد و مقدار نقطه کد را برمیگرداند::"
msgid ""
">>> chr(57344)\n"
"'\\ue000'\n"
">>> ord('\\ue000')\n"
"57344"
msgstr ""
">>> chr(57344)\n"
"'\\ue000'\n"
">>> ord('\\ue000')\n"
"57344"
msgid "Converting to Bytes"
msgstr "تبدیل به بایت"
msgid "The opposite method of :meth:`bytes.decode` is :meth:`str.encode`, which returns a :class:`bytes` representation of the Unicode string, encoded in the requested *encoding*."
msgstr "متد معکوس :meth:`bytes.decode`، :meth:`str.encode` است که یک بازنمایی :class:`bytes` از رشته یونیکد را برمیگرداند؛ این بازنمایی با *کدگذاری* درخواستی کدگذاری شده است."
msgid "The *errors* parameter is the same as the parameter of the :meth:`~bytes.decode` method but supports a few more possible handlers. As well as ``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case inserts a question mark instead of the unencodable character), there is also ``'xmlcharrefreplace'`` (inserts an XML character reference), ``backslashreplace`` (inserts a ``\\uNNNN`` escape sequence) and ``namereplace`` (inserts a ``\\N{...}`` escape sequence)."
msgstr "پارامتر *errors* همان پارامتر متد :meth:`~bytes.decode` است، اما از چند هندلر ممکن دیگر نیز پشتیبانی میکند. علاوه بر ``'strict'``، ``'ignore'`` و ``'replace'`` (که در این حالت بهجای نویسه غیرقابل کدگذاری، یک علامت سؤال درج میکند)، ``'xmlcharrefreplace'`` (که یک ارجاع نویسه XML درج میکند)، ``backslashreplace`` (که یک دنباله خنثیسازی ``\\uNNNN`` درج میکند) و ``namereplace`` (که یک دنباله خنثیسازی ``\\N{...}`` درج میکند) نیز وجود دارند."
msgid "The following example shows the different results::"
msgstr "مثال زیر نتایج متفاوت را نشان میدهد::"
msgid ""
">>> u = chr(40960) + 'abcd' + chr(1972)\n"
">>> u.encode('utf-8')\n"
"b'\\xea\\x80\\x80abcd\\xde\\xb4'\n"
">>> u.encode('ascii')\n"
"Traceback (most recent call last):\n"
" ...\n"
"UnicodeEncodeError: 'ascii' codec can't encode character '\\ua000' in\n"
" position 0: ordinal not in range(128)\n"
">>> u.encode('ascii', 'ignore')\n"
"b'abcd'\n"
">>> u.encode('ascii', 'replace')\n"
"b'?abcd?'\n"
">>> u.encode('ascii', 'xmlcharrefreplace')\n"
"b'ꀀabcd޴'\n"
">>> u.encode('ascii', 'backslashreplace')\n"
"b'\\\\ua000abcd\\\\u07b4'\n"
">>> u.encode('ascii', 'namereplace')\n"
"b'\\\\N{YI SYLLABLE IT}abcd\\\\u07b4'"
msgstr ""
">>> u = chr(40960) + 'abcd' + chr(1972)\n"
">>> u.encode('utf-8')\n"
"b'\\xea\\x80\\x80abcd\\xde\\xb4'\n"
">>> u.encode('ascii')\n"
"Traceback (most recent call last):\n"
" ...\n"
"UnicodeEncodeError: 'ascii' codec can't encode character '\\ua000' in\n"
" position 0: ordinal not in range(128)\n"
">>> u.encode('ascii', 'ignore')\n"
"b'abcd'\n"
">>> u.encode('ascii', 'replace')\n"
"b'?abcd?'\n"
">>> u.encode('ascii', 'xmlcharrefreplace')\n"
"b'ꀀabcd޴'\n"
">>> u.encode('ascii', 'backslashreplace')\n"
"b'\\\\ua000abcd\\\\u07b4'\n"
">>> u.encode('ascii', 'namereplace')\n"
"b'\\\\N{YI SYLLABLE IT}abcd\\\\u07b4'"
msgid "The low-level routines for registering and accessing the available encodings are found in the :mod:`codecs` module. Implementing new encodings also requires understanding the :mod:`codecs` module. However, the encoding and decoding functions returned by this module are usually more low-level than is comfortable, and writing new encodings is a specialized task, so the module won't be covered in this HOWTO."
msgstr "روالهای سطح پایین برای ثبت و دسترسی به کدگذاریهای موجود در ماژول :mod:`codecs` قرار دارند. پیادهسازی کدگذاریهای جدید نیز نیازمند درک ماژول :mod:`codecs` است. با این حال، توابع کدگذاری و کدگشایی که این ماژول برمیگرداند معمولاً سطح پایینتری از حد راحت دارند و نوشتن کدگذاریهای جدید وظیفهای تخصصی است، بنابراین این ماژول در این راهنمای عملی پوشش داده نخواهد شد."
msgid "Unicode Literals in Python Source Code"
msgstr "مقادیر لفظی یونیکد در کد منبع پایتون"
msgid "In Python source code, specific Unicode code points can be written using the ``\\u`` escape sequence, which is followed by four hex digits giving the code point. The ``\\U`` escape sequence is similar, but expects eight hex digits, not four::"
msgstr "در کد منبع پایتون، نقاط کد مشخص یونیکد را میتوان با استفاده از دنبالهی خنثیسازی ``\\u`` نوشت که پس از آن ۴ رقم مبنای شانزده میآید و نقطهکد را مشخص میکند. دنبالهی خنثیسازی ``\\U`` مشابه است، اما به ۸ رقم مبنای شانزده نیاز دارد، نه ۴::"
msgid ""
">>> s = \"a\\xac\\u1234\\u20ac\\U00008000\"\n"
"... # ^^^^ two-digit hex escape\n"
"... # ^^^^^^ four-digit Unicode escape\n"
"... # ^^^^^^^^^^ eight-digit Unicode escape\n"
">>> [ord(c) for c in s]\n"
"[97, 172, 4660, 8364, 32768]"
msgstr ""
">>> s = \"a\\xac\\u1234\\u20ac\\U00008000\"\n"
"... # ^^^^ two-digit hex escape\n"
"... # ^^^^^^ four-digit Unicode escape\n"
"... # ^^^^^^^^^^ eight-digit Unicode escape\n"
">>> [ord(c) for c in s]\n"
"[97, 172, 4660, 8364, 32768]"
msgid "Using escape sequences for code points greater than 127 is fine in small doses, but becomes an annoyance if you're using many accented characters, as you would in a program with messages in French or some other accent-using language. You can also assemble strings using the :func:`chr` built-in function, but this is even more tedious."
msgstr "استفاده از دنبالههای خنثیسازی برای نقاط کد بزرگتر از ۱۲۷ در مقادیر کم مشکلی ندارد، اما اگر از نویسههای لهجهدار زیادی استفاده کنید، آزاردهنده میشود؛ همانطور که در برنامهای با پیامهایی به فرانسوی یا زبان دیگری که از علامتهای تلفظی استفاده میکند، چنین خواهد بود. همچنین میتوانید رشتهها را با استفاده از تابع توکار :func:`chr` بسازید، اما این کار حتی خستهکنندهتر است."
msgid "Ideally, you'd want to be able to write literals in your language's natural encoding. You could then edit Python source code with your favorite editor which would display the accented characters naturally, and have the right characters used at runtime."
msgstr "در حالت ایدهآل، شما مایلید بتوانید مقادیر لفظی را با کدگذاری طبیعی زبان خود بنویسید. سپس میتوانید کد منبع پایتون را با ویرایشگر دلخواه خود ویرایش کنید، بهطوری که این ویرایشگر نویسههای دارای علامت تلفظ را بهصورت طبیعی نمایش میدهد و در رانتایم از نویسههای درست استفاده میشود."
msgid "Python supports writing source code in UTF-8 by default, but you can use almost any encoding if you declare the encoding being used. This is done by including a special comment as either the first or second line of the source file::"
msgstr "پایتون بهطور پیشفرض از نوشتن کد منبع بهصورت UTF-8 پشتیبانی میکند، اما اگر کدگذاری استفادهشده را اعلام کنید، میتوانید تقریباً از هر کدگذاری استفاده کنید. این کار با قرار دادن یک کامنت ویژه بهعنوان خط اول یا دوم پرونده منبع انجام میشود::"
msgid ""
"#!/usr/bin/env python\n"
"# -*- coding: latin-1 -*-\n"
"\n"
"u = 'abcdé'\n"
"print(ord(u[-1]))"
msgstr ""
"#!/usr/bin/env python\n"
"# -*- coding: latin-1 -*-\n"
"\n"
"u = 'abcdé'\n"
"print(ord(u[-1]))"
msgid "The syntax is inspired by Emacs's notation for specifying variables local to a file. Emacs supports many different variables, but Python only supports 'coding'. The ``-*-`` symbols indicate to Emacs that the comment is special; they have no significance to Python but are a convention. Python looks for ``coding: name`` or ``coding=name`` in the comment."
msgstr "این سینتکس از نمادگذاری Emacs برای مشخص کردن متغیرهای محلی یک پرونده الهام گرفته است. Emacs از متغیرهای مختلفی پشتیبانی میکند، اما Python فقط از 'coding' پشتیبانی میکند. نمادهای ``-*-`` به Emacs نشان میدهند که آن کامنت ویژه است؛ این نمادها برای Python هیچ معنایی ندارند، اما یک قرارداد هستند. Python در کامنت به دنبال ``coding: name`` یا ``coding=name`` میگردد."
msgid "If you don't include such a comment, the default encoding used will be UTF-8 as already mentioned. See also :pep:`263` for more information."
msgstr "اگر چنین کامنتی را وارد نکنید، همانطور که پیشتر ذکر شد، کدگذاری پیشفرض بهکاررفته UTF-8 خواهد بود. برای اطلاعات بیشتر، :pep:`263` را نیز ببینید."
msgid "Unicode Properties"
msgstr "ویژگیهای یونیکد"
msgid "The Unicode specification includes a database of information about code points. For each defined code point, the information includes the character's name, its category, the numeric value if applicable (for characters representing numeric concepts such as the Roman numerals, fractions such as one-third and four-fifths, etc.). There are also display-related properties, such as how to use the code point in bidirectional text."
msgstr "مشخصات یونیکد شامل پایگاه دادهای از اطلاعات درباره نقاط کد است. برای هر نقطهکد تعریفشده، این اطلاعات شامل نام نویسه، دستهی آن، و مقدار عددی در صورت وجود (برای نویسههایی که مفاهیم عددی را نشان میدهند، مانند اعداد رومی، کسرهایی مانند یکسوم و چهارپنجم و غیره) است. همچنین ویژگیهای مربوط به نمایش نیز وجود دارند، مانند چگونگی استفاده از نقطهکد در متن دوجهته."
msgid "The following program displays some information about several characters, and prints the numeric value of one particular character::"
msgstr "برنامه زیر اطلاعاتی دربارهی چند نویسه نمایش میدهد و مقدار عددی یک نویسه خاص را چاپ میکند::"
msgid ""
"import unicodedata\n"
"\n"
"u = chr(233) + chr(0x0bf2) + chr(3972) + chr(6000) + chr(13231)\n"
"\n"
"for i, c in enumerate(u):\n"
" print(i, '%04x' % ord(c), unicodedata.category(c), end=\" \")\n"
" print(unicodedata.name(c))\n"
"\n"
"# Get numeric value of second character\n"
"print(unicodedata.numeric(u[1]))"
msgstr ""
"import unicodedata\n"
"\n"
"u = chr(233) + chr(0x0bf2) + chr(3972) + chr(6000) + chr(13231)\n"
"\n"
"for i, c in enumerate(u):\n"
" print(i, '%04x' % ord(c), unicodedata.category(c), end=\" \")\n"
" print(unicodedata.name(c))\n"
"\n"
"# Get numeric value of second character\n"
"print(unicodedata.numeric(u[1]))"
msgid "When run, this prints:"
msgstr "هنگام اجرا، این چاپ میشود:"
msgid ""
"0 00e9 Ll LATIN SMALL LETTER E WITH ACUTE\n"
"1 0bf2 No TAMIL NUMBER ONE THOUSAND\n"
"2 0f84 Mn TIBETAN MARK HALANTA\n"
"3 1770 Lo TAGBANWA LETTER SA\n"
"4 33af So SQUARE RAD OVER S SQUARED\n"
"1000.0"
msgstr ""
"0 00e9 Ll LATIN SMALL LETTER E WITH ACUTE\n"
"1 0bf2 No TAMIL NUMBER ONE THOUSAND\n"
"2 0f84 Mn TIBETAN MARK HALANTA\n"
"3 1770 Lo TAGBANWA LETTER SA\n"
"4 33af So SQUARE RAD OVER S SQUARED\n"
"1000.0"
msgid "The category codes are abbreviations describing the nature of the character. These are grouped into categories such as \"Letter\", \"Number\", \"Punctuation\", or \"Symbol\", which in turn are broken up into subcategories. To take the codes from the above output, ``'Ll'`` means 'Letter, lowercase', ``'No'`` means \"Number, other\", ``'Mn'`` is \"Mark, nonspacing\", and ``'So'`` is \"Symbol, other\". See `the General Category Values section of the Unicode Character Database documentation <https://www.unicode.org/reports/tr44/#General_Category_Values>`_ for a list of category codes."
msgstr "کدهای دسته، مخففهایی هستند که ماهیت نویسه را توصیف میکنند. این کدها در دستههایی مانند «حرف (Letter)»، «عدد (Number)»، «نمادگذاری (Punctuation)» یا «نماد (Symbol)» گروهبندی میشوند و این دستهها خود به زیردستههایی تقسیم میشوند. با در نظر گرفتن کدهای خروجی بالا، ``'Ll'`` به معنای «حرف، کوچک (Letter, lowercase)»، ``'No'`` به معنای «عدد، دیگر (Number, other)»، ``'Mn'`` به معنای «علامت، بدون فاصله (Mark, nonspacing)» و ``'So'`` به معنای «نماد، دیگر (Symbol, other)» است. برای مشاهدهی فهرستی از کدهای دسته، `بخش General Category Values در مستندات Unicode Character Database <https://www.unicode.org/reports/tr44/#General_Category_Values>`_ را ببینید."
msgid "Comparing Strings"
msgstr "مقایسه رشتهها"
msgid "Unicode adds some complication to comparing strings, because the same set of characters can be represented by different sequences of code points. For example, a letter like 'ê' can be represented as a single code point U+00EA, or as U+0065 U+0302, which is the code point for 'e' followed by a code point for 'COMBINING CIRCUMFLEX ACCENT'. These will produce the same output when printed, but one is a string of length 1 and the other is of length 2."
msgstr "یونیکد مقایسهی رشتهها را تا حدی پیچیده میکند، زیرا مجموعهی یکسانی از نویسهها میتواند با دنبالههای متفاوتی از نقطهکدها نمایش داده شود. برای مثال، نویسهای مانند 'ê' میتواند بهصورت یک نقطهکد U+00EA، یا بهصورت U+0065 U+0302 نمایش داده شود، یعنی نقطهکدِ 'e' که پس از آن نقطهکدی برای 'COMBINING CIRCUMFLEX ACCENT' میآید. این دو هنگام چاپ خروجی یکسانی تولید میکنند، اما یکی رشتهای به طول ۱ و دیگری رشتهای به طول ۲ است."
msgid "One tool for a case-insensitive comparison is the :meth:`~str.casefold` string method that converts a string to a case-insensitive form following an algorithm described by the Unicode Standard. This algorithm has special handling for characters such as the German letter 'ß' (code point U+00DF), which becomes the pair of lowercase letters 'ss'."
msgstr "یکی از ابزارها برای مقایسهی بدون حساسیت به بزرگی و کوچکی حروف، متد رشتهای :meth:`~str.casefold` است که رشته را با پیروی از الگوریتمی توصیفشده در استاندارد یونیکد به شکلی بدون حساسیت به بزرگی و کوچکی حروف تبدیل میکند. این الگوریتم برای نویسههایی مانند حرف آلمانی 'ß' (نقطه کد U+00DF) که به جفت حرف کوچک 'ss' تبدیل میشود، برخورد ویژهای دارد."
msgid ""
">>> street = 'Gürzenichstraße'\n"
">>> street.casefold()\n"
"'gürzenichstrasse'"
msgstr ""
">>> street = 'Gürzenichstraße'\n"
">>> street.casefold()\n"
"'gürzenichstrasse'"
msgid "A second tool is the :mod:`unicodedata` module's :func:`~unicodedata.normalize` function that converts strings to one of several normal forms, where letters followed by a combining character are replaced with single characters. :func:`~unicodedata.normalize` can be used to perform string comparisons that won't falsely report inequality if two strings use combining characters differently:"
msgstr "ابزار دوم، تابع :func:`~unicodedata.normalize` در ماژول :mod:`unicodedata` است که رشتهها را به یکی از چند صورت نرمال تبدیل میکند؛ در این صورتهای نرمال، حروفی که پس از آنها یک نویسه ترکیبی آمده است با نویسههای تکی جایگزین میشوند. میتوان از :func:`~unicodedata.normalize` برای انجام مقایسهی رشتهها استفاده کرد تا اگر دو رشته بهشکل متفاوتی از نویسههای ترکیبی استفاده میکنند، نابرابری بهاشتباه گزارش نشود:"
msgid ""
"import unicodedata\n"
"\n"
"def compare_strs(s1, s2):\n"
" def NFD(s):\n"
" return unicodedata.normalize('NFD', s)\n"
"\n"
" return NFD(s1) == NFD(s2)\n"
"\n"
"single_char = 'ê'\n"
"multiple_chars = '\\N{LATIN SMALL LETTER E}\\N{COMBINING CIRCUMFLEX ACCENT}'\n"
"print('length of first string=', len(single_char))\n"
"print('length of second string=', len(multiple_chars))\n"
"print(compare_strs(single_char, multiple_chars))"
msgstr ""
"import unicodedata\n"
"\n"
"def compare_strs(s1, s2):\n"
" def NFD(s):\n"
" return unicodedata.normalize('NFD', s)\n"
"\n"
" return NFD(s1) == NFD(s2)\n"
"\n"
"single_char = 'ê'\n"
"multiple_chars = '\\N{LATIN SMALL LETTER E}\\N{COMBINING CIRCUMFLEX ACCENT}'\n"
"print('length of first string=', len(single_char))\n"
"print('length of second string=', len(multiple_chars))\n"
"print(compare_strs(single_char, multiple_chars))"
msgid "When run, this outputs:"
msgstr "هنگام اجرا، این خروجی را میدهد:"
msgid ""
"$ python compare-strs.py\n"
"length of first string= 1\n"
"length of second string= 2\n"
"True"
msgstr ""
"$ python compare-strs.py\n"
"length of first string= 1\n"
"length of second string= 2\n"
"True"
msgid "The first argument to the :func:`~unicodedata.normalize` function is a string giving the desired normalization form, which can be one of 'NFC', 'NFKC', 'NFD', and 'NFKD'."
msgstr "اولین آرگومان تابع :func:`~unicodedata.normalize` رشتهای است که فرم نرمالسازی مورد نظر را مشخص میکند و میتواند یکی از 'NFC'، 'NFKC'، 'NFD' و 'NFKD' باشد."
msgid "The Unicode Standard also specifies how to do caseless comparisons::"
msgstr "استاندارد یونیکد همچنین چگونگی انجام مقایسههای بدون حساسیت به بزرگی و کوچکی حروف را مشخص میکند::"
msgid ""
"import unicodedata\n"
"\n"
"def compare_caseless(s1, s2):\n"
" def NFD(s):\n"
" return unicodedata.normalize('NFD', s)\n"
"\n"
" return NFD(NFD(s1).casefold()) == NFD(NFD(s2).casefold())\n"
"\n"
"# Example usage\n"
"single_char = 'ê'\n"
"multiple_chars = '\\N{LATIN CAPITAL LETTER E}\\N{COMBINING CIRCUMFLEX ACCENT}'\n"
"\n"
"print(compare_caseless(single_char, multiple_chars))"
msgstr ""
"import unicodedata\n"
"\n"
"def compare_caseless(s1, s2):\n"
" def NFD(s):\n"
" return unicodedata.normalize('NFD', s)\n"
"\n"
" return NFD(NFD(s1).casefold()) == NFD(NFD(s2).casefold())\n"
"\n"
"# Example usage\n"
"single_char = 'ê'\n"
"multiple_chars = '\\N{LATIN CAPITAL LETTER E}\\N{COMBINING CIRCUMFLEX ACCENT}'\n"
"\n"
"print(compare_caseless(single_char, multiple_chars))"
msgid "This will print ``True``. (Why is :func:`!NFD` invoked twice? Because there are a few characters that make :meth:`~str.casefold` return a non-normalized string, so the result needs to be normalized again. See section 3.13 of the Unicode Standard for a discussion and an example.)"
msgstr "این ``True`` را چاپ میکند. (چرا :func:`!NFD` دو بار فراخوانی میشود؟ زیرا چند نویسه باعث میشوند :meth:`~str.casefold` یک رشتهی غیرنرمال را بازگرداند، بنابراین نتیجه باید دوباره نرمالسازی شود. برای توضیح و یک نمونه، بخش 3.13 استاندارد یونیکد را ببینید.)"
msgid "Unicode Regular Expressions"
msgstr "عبارتهای باقاعده یونیکد"
msgid "The regular expressions supported by the :mod:`re` module can be provided either as bytes or strings. Some of the special character sequences such as ``\\d`` and ``\\w`` have different meanings depending on whether the pattern is supplied as bytes or a string. For example, ``\\d`` will match the characters ``[0-9]`` in bytes but in strings will match any character that's in the ``'Nd'`` category."
msgstr "عبارتهای باقاعده پشتیبانیشده توسط ماژول :mod:`re` را میتوان بهصورت بایت یا رشته ارائه کرد. برخی از دنبالههای نویسهای خاص مانند ``\\d`` و ``\\w`` معانی متفاوتی دارند، بسته به اینکه الگو بهصورت بایت یا رشته ارائه شود. برای مثال، ``\\d`` در بایتها با نویسههای ``[0-9]`` مطابقت میکند، اما در رشتهها با هر نویسهای که در دسته ``'Nd'`` باشد مطابقت میکند."
msgid "The string in this example has the number 57 written in both Thai and Arabic numerals::"
msgstr "در این مثال، عدد ۵۷ در رشته هم با ارقام تایلندی و هم با ارقام عربی نوشته شده است::"
msgid ""
"import re\n"
"p = re.compile(r'\\d+')\n"
"\n"
"s = \"Over \\u0e55\\u0e57 57 flavours\"\n"
"m = p.search(s)\n"
"print(repr(m.group()))"
msgstr ""
"import re\n"
"p = re.compile(r'\\d+')\n"
"\n"
"s = \"Over \\u0e55\\u0e57 57 flavours\"\n"
"m = p.search(s)\n"
"print(repr(m.group()))"
msgid "When executed, ``\\d+`` will match the Thai numerals and print them out. If you supply the :const:`re.ASCII` flag to :func:`~re.compile`, ``\\d+`` will match the substring \"57\" instead."
msgstr "هنگام اجرا، ``\\d+`` با ارقام تایلندی تطابق پیدا میکند و آنها را چاپ میکند. اگر پرچم :const:`re.ASCII` را به :func:`~re.compile` بدهید، ``\\d+`` در عوض با زیررشتهی «57» تطابق پیدا میکند."
msgid "Similarly, ``\\w`` matches a wide variety of Unicode characters but only ``[a-zA-Z0-9_]`` in bytes or if :const:`re.ASCII` is supplied, and ``\\s`` will match either Unicode whitespace characters or ``[ \\t\\n\\r\\f\\v]``."
msgstr "بهطور مشابه، ``\\w`` با طیف وسیعی از نویسههای یونیکد مطابقت میکند، اما در بایتها یا اگر :const:`re.ASCII` ارائه شده باشد، فقط با ``[a-zA-Z0-9_]`` مطابقت میکند، و ``\\s`` با نویسههای فضای سفید یونیکد یا ``[ \\t\\n\\r\\f\\v]`` مطابقت خواهد کرد."
msgid "Some good alternative discussions of Python's Unicode support are:"
msgstr "برخی بحثهای جایگزین خوب دربارهی پشتیبانی پایتون از یونیکد عبارتند از:"
msgid "`Processing Text Files in Python 3 <https://python-notes.curiousefficiency.org/en/latest/python3/text_file_processing.html>`_, by Nick Coghlan."
msgstr "`پردازش پروندههای متنی در پایتون 3 <https://python-notes.curiousefficiency.org/en/latest/python3/text_file_processing.html>`_، اثر Nick Coghlan."
msgid "`Pragmatic Unicode <https://nedbatchelder.com/text/unipain.html>`_, a PyCon 2012 presentation by Ned Batchelder."
msgstr "`Pragmatic Unicode <https://nedbatchelder.com/text/unipain.html>`_، ارائهای از Ned Batchelder در PyCon ۲۰۱۲."
msgid "The :class:`str` type is described in the Python library reference at :ref:`textseq`."
msgstr "نوع :class:`str` در مرجع کتابخانهی پایتون، در :ref:`textseq` شرح داده شده است."
msgid "The documentation for the :mod:`unicodedata` module."
msgstr "مستندات ماژول :mod:`unicodedata`."
msgid "The documentation for the :mod:`codecs` module."
msgstr "مستندات ماژول :mod:`codecs`."
msgid "Marc-André Lemburg gave `a presentation titled \"Python and Unicode\" (PDF slides) <https://downloads.egenix.com/python/Unicode-EPC2002-Talk.pdf>`_ at EuroPython 2002. The slides are an excellent overview of the design of Python 2's Unicode features (where the Unicode string type is called ``unicode`` and literals start with ``u``)."
msgstr "مارک آندره لمبورگ در EuroPython 2002 `ارائهای با عنوان «Python and Unicode» (اسلایدهای PDF) <https://downloads.egenix.com/python/Unicode-EPC2002-Talk.pdf>`_ داشت. این اسلایدها مروری عالی بر طراحی قابلیتهای یونیکد Python 2 است (که در آن نوع رشته یونیکد ``unicode`` نامیده میشود و لفظها با ``u`` شروع میشوند)."
msgid "Reading and Writing Unicode Data"
msgstr "خواندن و نوشتن دادههای یونیکد"
msgid "Once you've written some code that works with Unicode data, the next problem is input/output. How do you get Unicode strings into your program, and how do you convert Unicode into a form suitable for storage or transmission?"
msgstr "پس از اینکه کدی نوشتید که با دادههای یونیکد کار میکند، مسئلهی بعدی ورودی/خروجی است. چگونه رشتههای یونیکد را وارد برنامهتان کنید، و چگونه یونیکد را به شکلی مناسب برای ذخیرهسازی یا انتقال تبدیل کنید؟"
msgid "It's possible that you may not need to do anything depending on your input sources and output destinations; you should check whether the libraries used in your application support Unicode natively. XML parsers often return Unicode data, for example. Many relational databases also support Unicode-valued columns and can return Unicode values from an SQL query."
msgstr "ممکن است بسته به منابع ورودی و مقاصد خروجی خود نیازی به انجام هیچ کاری نداشته باشید؛ باید بررسی کنید که آیا کتابخانههای استفادهشده در برنامه شما بهصورت بومی از یونیکد پشتیبانی میکنند یا خیر. برای مثال، پارسرهای XML اغلب دادههای یونیکد را برمیگردانند. بسیاری از پایگاههای داده رابطهای نیز از ستونهایی با مقادیر یونیکد پشتیبانی میکنند و میتوانند مقادیر یونیکد را از یک پرسوجوی SQL برگردانند."
msgid "Unicode data is usually converted to a particular encoding before it gets written to disk or sent over a socket. It's possible to do all the work yourself: open a file, read an 8-bit bytes object from it, and convert the bytes with ``bytes.decode(encoding)``. However, the manual approach is not recommended."
msgstr "دادههای یونیکد معمولاً پیش از آنکه روی دیسک نوشته شوند یا از طریق سوکت ارسال شوند، به یک کدگذاری مشخص تبدیل میشوند. میتوانید تمام این کارها را خودتان انجام دهید: پروندهای را باز کنید، یک شیء بایتی ۸بیتی از آن بخوانید و بایتها را با ``bytes.decode(encoding)`` تبدیل کنید. با این حال، روش دستی توصیه نمیشود."
msgid "One problem is the multi-byte nature of encodings; one Unicode character can be represented by several bytes. If you want to read the file in arbitrary-sized chunks (say, 1024 or 4096 bytes), you need to write error-handling code to catch the case where only part of the bytes encoding a single Unicode character are read at the end of a chunk. One solution would be to read the entire file into memory and then perform the decoding, but that prevents you from working with files that are extremely large; if you need to read a 2 GiB file, you need 2 GiB of RAM. (More, really, since for at least a moment you'd need to have both the encoded string and its Unicode version in memory.)"
msgstr "یکی از مشکلات، ماهیت چندبایتی کدگذاریهاست؛ یک نویسهی یونیکد میتواند با چند بایت بازنمایی شود. اگر بخواهید پرونده را بهصورت تکههایی با اندازهی دلخواه (مثلاً ۱۰۲۴ یا ۴۰۹۶ بایت) بخوانید، باید کد مدیریت خطایی برای پوشش حالتی بنویسید که در آن تنها بخشی از بایتهایی که یک نویسهی یونیکد را کدگذاری میکنند، در انتهای یک تکه خوانده میشود. یک راهحل میتواند این باشد که کل پرونده را در حافظه بخوانید و سپس کدگشایی را انجام دهید، اما این کار شما را از کار با پروندههای بسیار بزرگ بازمیدارد؛ اگر نیاز داشته باشید پروندهی ۲ GiB را بخوانید، به ۲ GiB حافظهی RAM نیاز دارید. (در واقع بیشتر، زیرا حداقل برای یک لحظه باید هم رشتهی کدگذاریشده و هم نسخهی یونیکد آن را در حافظه داشته باشید.)"
msgid "The solution would be to use the low-level decoding interface to catch the case of partial coding sequences. The work of implementing this has already been done for you: the built-in :func:`open` function can return a file-like object that assumes the file's contents are in a specified encoding and accepts Unicode parameters for methods such as :meth:`~io.TextIOBase.read` and :meth:`~io.TextIOBase.write`. This works through :func:`open`\\'s *encoding* and *errors* parameters which are interpreted just like those in :meth:`str.encode` and :meth:`bytes.decode`."
msgstr "راهحل این است که از رابط کدگشایی سطح پایین برای تشخیص حالت دنبالههای کدگذاری ناقص استفاده شود. کار پیادهسازی این مورد قبلاً برای شما انجام شده است: تابع توکار :func:`open` میتواند یک شیء شبهپرونده برگرداند که فرض میکند محتوای پرونده در یک کدگذاری مشخص قرار دارد و پارامترهای یونیکد را برای متدهایی مانند :meth:`~io.TextIOBase.read` و :meth:`~io.TextIOBase.write` میپذیرد. این کار از طریق پارامترهای *encoding* و *errors* در :func:`open` انجام میشود که دقیقاً مانند پارامترهای موجود در :meth:`str.encode` و :meth:`bytes.decode` تفسیر میشوند."
msgid "Reading Unicode from a file is therefore simple::"
msgstr "بنابراین، خواندن یونیکد از یک پرونده ساده است::"
msgid ""
"with open('unicode.txt', encoding='utf-8') as f:\n"
" for line in f:\n"
" print(repr(line))"
msgstr ""
"with open('unicode.txt', encoding='utf-8') as f:\n"
" for line in f:\n"
" print(repr(line))"
msgid "It's also possible to open files in update mode, allowing both reading and writing::"
msgstr "همچنین میتوانید پروندهها را در حالت بهروزرسانی باز کنید، که امکان خواندن و نوشتن را فراهم میکند::"
msgid ""
"with open('test', encoding='utf-8', mode='w+') as f:\n"
" f.write('\\u4500 blah blah blah\\n')\n"
" f.seek(0)\n"
" print(repr(f.readline()[:1]))"
msgstr ""
"with open('test', encoding='utf-8', mode='w+') as f:\n"
" f.write('\\u4500 blah blah blah\\n')\n"
" f.seek(0)\n"
" print(repr(f.readline()[:1]))"
msgid "The Unicode character ``U+FEFF`` is used as a byte-order mark (BOM), and is often written as the first character of a file in order to assist with autodetection of the file's byte ordering. Some encodings, such as UTF-16, expect a BOM to be present at the start of a file; when such an encoding is used, the BOM will be automatically written as the first character and will be silently dropped when the file is read. There are variants of these encodings, such as 'utf-16-le' and 'utf-16-be' for little-endian and big-endian encodings, that specify one particular byte ordering and don't skip the BOM."
msgstr "نویسهی یونیکد ``U+FEFF`` بهعنوان نشانگر ترتیب بایت (BOM) استفاده میشود و اغلب بهعنوان نخستین نویسهی یک پرونده نوشته میشود تا به تشخیص خودکار ترتیب بایتهای پرونده کمک کند. برخی کدگذاریها، مانند UTF-16، انتظار دارند که یک BOM در ابتدای پرونده وجود داشته باشد؛ هنگامی که از چنین کدگذاریای استفاده شود، BOM بهصورت خودکار بهعنوان نخستین نویسه نوشته میشود و هنگام خواندن پرونده، بهطور خاموش حذف میشود. گونههایی از این کدگذاریها وجود دارند، مانند 'utf-16-le' و 'utf-16-be' برای کدگذاریهایی با بایت کوچکاندیان (little-endian) و بزرگاندیان (big-endian)، که یک ترتیب بایت مشخص را تعیین میکنند و BOM را نادیده نمیگیرند."
msgid "In some areas, it is also convention to use a \"BOM\" at the start of UTF-8 encoded files; the name is misleading since UTF-8 is not byte-order dependent. The mark simply announces that the file is encoded in UTF-8. For reading such files, use the 'utf-8-sig' codec to automatically skip the mark if present."
msgstr "در برخی حوزهها، همچنین مرسوم است که از «BOM» در ابتدای پروندههای کدگذاریشده با UTF-8 استفاده شود؛ این نام گمراهکننده است، زیرا UTF-8 به ترتیب بایتها وابسته نیست. این نشانه صرفاً اعلام میکند که پرونده با UTF-8 کدگذاری شده است. برای خواندن چنین پروندههایی، از کدک 'utf-8-sig' استفاده کنید تا در صورت وجود نشانه، بهطور خودکار آن را نادیده بگیرد."
msgid "Unicode filenames"
msgstr "نامپروندههای یونیکد"
msgid "Most of the operating systems in common use today support filenames that contain arbitrary Unicode characters. Usually this is implemented by converting the Unicode string into some encoding that varies depending on the system. Today Python is converging on using UTF-8: Python on MacOS has used UTF-8 for several versions, and Python 3.6 switched to using UTF-8 on Windows as well. On Unix systems, there will only be a :term:`filesystem encoding <filesystem encoding and error handler>`. if you've set the ``LANG`` or ``LC_CTYPE`` environment variables; if you haven't, the default encoding is again UTF-8."
msgstr "بیشتر سیستمعاملهای رایج امروزی از نام پروندههایی که حاوی نویسههای یونیکد دلخواه هستند پشتیبانی میکنند. معمولاً این کار با تبدیل رشته یونیکدی به یک کدگذاری خاص پیادهسازی میشود که بسته به سیستم متفاوت است. امروزه پایتون در حال همگرایی به سمت استفاده از UTF-8 است: پایتون در MacOS برای چندین نسخه از UTF-8 استفاده کرده است و پایتون 3.6 نیز در ویندوز به استفاده از UTF-8 روی آورد. در سیستمهای یونیکسی، تنها در صورتی یک :term:`کدگذاری سامانه فایلبندی <filesystem encoding and error handler>` وجود خواهد داشت که متغیرهای محیطی ``LANG`` یا ``LC_CTYPE`` را تنظیم کرده باشید؛ در غیر این صورت، کدگذاری پیشفرض باز هم UTF-8 است."
msgid "The :func:`sys.getfilesystemencoding` function returns the encoding to use on your current system, in case you want to do the encoding manually, but there's not much reason to bother. When opening a file for reading or writing, you can usually just provide the Unicode string as the filename, and it will be automatically converted to the right encoding for you::"
msgstr "تابع :func:`sys.getfilesystemencoding` کدگذاری مورد استفاده در سیستم فعلی شما را برمیگرداند، در صورتی که بخواهید کدگذاری را بهصورت دستی انجام دهید، اما دلیل چندانی برای زحمت کشیدن وجود ندارد. هنگام باز کردن یک پرونده برای خواندن یا نوشتن، معمولاً میتوانید فقط رشتهی Unicode را بهعنوان نام پرونده ارائه دهید، و بهطور خودکار به کدگذاری مناسب برای شما تبدیل میشود::"
msgid ""
"filename = 'filename\\u4500abc'\n"
"with open(filename, 'w') as f:\n"
" f.write('blah\\n')"
msgstr ""
"filename = 'filename\\u4500abc'\n"
"with open(filename, 'w') as f:\n"
" f.write('blah\\n')"
msgid "Functions in the :mod:`os` module such as :func:`os.stat` will also accept Unicode filenames."
msgstr "توابع ماژول :mod:`os` مانند :func:`os.stat` همچنین نام پروندههای یونیکد را میپذیرند."
msgid "The :func:`os.listdir` function returns filenames, which raises an issue: should it return the Unicode version of filenames, or should it return bytes containing the encoded versions? :func:`os.listdir` can do both, depending on whether you provided the directory path as bytes or a Unicode string. If you pass a Unicode string as the path, filenames will be decoded using the filesystem's encoding and a list of Unicode strings will be returned, while passing a byte path will return the filenames as bytes. For example, assuming the default :term:`filesystem encoding <filesystem encoding and error handler>` is UTF-8, running the following program::"
msgstr "تابع :func:`os.listdir` نام پروندهها را برمیگرداند، که این موضوع مسئلهای را مطرح میکند: آیا باید نسخهی یونیکد نام پروندهها را برگرداند، یا باید بایتهایی شامل نسخههای کدگذاریشده را برگرداند؟ :func:`os.listdir` میتواند هر دو کار را انجام دهد، بسته به اینکه مسیر پوشه را بهصورت بایت یا یک رشتهی یونیکد ارائه کرده باشید. اگر یک رشتهی یونیکد را بهعنوان مسیر بدهید، نام پروندهها با استفاده از کدگذاری سامانه فایلبندی کدگشایی میشوند و فهرستی از رشتههای یونیکد برگردانده میشود، در حالی که دادن یک مسیر بایتی، نام پروندهها را بهصورت بایت برمیگرداند. برای مثال، با فرض اینکه :term:`کدگذاری سامانه فایلبندی <filesystem encoding and error handler>` پیشفرض UTF-8 باشد، اجرای برنامهی زیر::"
msgid ""
"fn = 'filename\\u4500abc'\n"
"f = open(fn, 'w')\n"
"f.close()\n"
"\n"
"import os\n"
"print(os.listdir(b'.'))\n"
"print(os.listdir('.'))"
msgstr ""
"fn = 'filename\\u4500abc'\n"
"f = open(fn, 'w')\n"
"f.close()\n"
"\n"
"import os\n"
"print(os.listdir(b'.'))\n"
"print(os.listdir('.'))"
msgid "will produce the following output:"
msgstr "خروجی زیر را تولید خواهد کرد:"
msgid ""
"$ python listdir-test.py\n"
"[b'filename\\xe4\\x94\\x80abc', ...]\n"
"['filename\\u4500abc', ...]"
msgstr ""
"$ python listdir-test.py\n"
"[b'filename\\xe4\\x94\\x80abc', ...]\n"
"['filename\\u4500abc', ...]"
msgid "The first list contains UTF-8-encoded filenames, and the second list contains the Unicode versions."
msgstr "نخستین فهرست شامل نام پروندههای کدگذاریشده با UTF-8 است، و دومین فهرست شامل نسخههای یونیکد است."
msgid "Note that on most occasions, you should can just stick with using Unicode with these APIs. The bytes APIs should only be used on systems where undecodable file names can be present; that's pretty much only Unix systems now."
msgstr "توجه داشته باشید که در بیشتر موارد، میتوانید صرفاً به استفاده از Unicode با این APIها اکتفا کنید. APIهای bytes فقط باید در سیستمهایی استفاده شوند که ممکن است نام پروندههای غیرقابل کدگشایی در آنها وجود داشته باشد؛ این موضوع امروزه تقریباً فقط در مورد سیستمهای یونیکس صدق میکند."
msgid "Tips for Writing Unicode-aware Programs"
msgstr "نکاتی برای نوشتن برنامههای آگاه از یونیکد"
msgid "This section provides some suggestions on writing software that deals with Unicode."
msgstr "این بخش چند پیشنهاد دربارهی نوشتن نرمافزاری که با یونیکد سروکار دارد ارائه میدهد."
msgid "The most important tip is:"
msgstr "مهمترین نکته این است:"
msgid "Software should only work with Unicode strings internally, decoding the input data as soon as possible and encoding the output only at the end."
msgstr "نرمافزار باید در درون خود فقط با رشتههای یونیکد کار کند، دادههای ورودی را هرچه زودتر کدگشایی کند و خروجی را فقط در پایان کدگذاری کند."
msgid "If you attempt to write processing functions that accept both Unicode and byte strings, you will find your program vulnerable to bugs wherever you combine the two different kinds of strings. There is no automatic encoding or decoding: if you do e.g. ``str + bytes``, a :exc:`TypeError` will be raised."
msgstr "اگر تلاش کنید توابع پردازشی بنویسید که هم رشتههای یونیکد و هم رشتههای بایتی را میپذیرند، متوجه خواهید شد که برنامهی شما هر جا که این دو نوع مختلف رشته را با هم ترکیب کنید، در برابر اشکالها آسیبپذیر است. هیچ کدگذاری یا کدگشایی خودکاری وجود ندارد: اگر برای مثال ``str + bytes`` را انجام دهید، یک :exc:`TypeError` پرتاب خواهد شد."
msgid "When using data coming from a web browser or some other untrusted source, a common technique is to check for illegal characters in a string before using the string in a generated command line or storing it in a database. If you're doing this, be careful to check the decoded string, not the encoded bytes data; some encodings may have interesting properties, such as not being bijective or not being fully ASCII-compatible. This is especially true if the input data also specifies the encoding, since the attacker can then choose a clever way to hide malicious text in the encoded bytestream."
msgstr "هنگام استفاده از دادههایی که از یک مرورگر وب یا منبع دیگری غیرقابلاعتماد میآیند، روشی رایج این است که پیش از استفاده از یک رشته در خط فرمان تولیدشده یا ذخیره آن در پایگاه داده، وجود نویسههای غیرمجاز در آن رشته بررسی شود. اگر این کار را انجام میدهید، دقت کنید که رشته کدگشاییشده را بررسی کنید، نه داده بایتی کدگذاریشده را؛ برخی کدگذاریها ممکن است ویژگیهای قابلتوجهی داشته باشند، مانند دوسویی نبودن یا بهطور کامل با ASCII سازگار نبودن. این موضوع بهویژه زمانی صادق است که داده ورودی نیز کدگذاری را مشخص کند، زیرا در این صورت مهاجم میتواند راهی هوشمندانه برای پنهان کردن متن مخرب در جریان بایتی کدگذاریشده انتخاب کند."
msgid "Converting Between File Encodings"
msgstr "تبدیل بین کدگذاریهای پرونده"
msgid "The :class:`~codecs.StreamRecoder` class can transparently convert between encodings, taking a stream that returns data in encoding #1 and behaving like a stream returning data in encoding #2."
msgstr "کلاس :class:`~codecs.StreamRecoder` میتواند بهصورت شفاف بین کدگذاریها تبدیل انجام دهد؛ این کلاس جریانی را میگیرد که دادهها را در کدگذاری #۱ برمیگرداند و مانند جریانی رفتار میکند که دادهها را در کدگذاری #۲ برمیگرداند."
msgid "For example, if you have an input file *f* that's in Latin-1, you can wrap it with a :class:`~codecs.StreamRecoder` to return bytes encoded in UTF-8::"
msgstr "برای مثال، اگر یک پرونده ورودی *f* دارید که با Latin-1 کدگذاری شده است، میتوانید آن را با یک :class:`~codecs.StreamRecoder` بپیچید تا بایتهای کدگذاریشده با UTF-8 را برگرداند::"
msgid ""
"new_f = codecs.StreamRecoder(f,\n"
" # en/decoder: used by read() to encode its results and\n"
" # by write() to decode its input.\n"
" codecs.getencoder('utf-8'), codecs.getdecoder('utf-8'),\n"
"\n"
" # reader/writer: used to read and write to the stream.\n"
" codecs.getreader('latin-1'), codecs.getwriter('latin-1') )"
msgstr ""
"new_f = codecs.StreamRecoder(f,\n"
" # en/decoder: used by read() to encode its results and\n"
" # by write() to decode its input.\n"
" codecs.getencoder('utf-8'), codecs.getdecoder('utf-8'),\n"
"\n"
" # reader/writer: used to read and write to the stream.\n"
" codecs.getreader('latin-1'), codecs.getwriter('latin-1') )"
msgid "Files in an Unknown Encoding"
msgstr "پروندههایی با کدگذاری ناشناخته"
msgid "What can you do if you need to make a change to a file, but don't know the file's encoding? If you know the encoding is ASCII-compatible and only want to examine or modify the ASCII parts, you can open the file with the ``surrogateescape`` error handler::"
msgstr "اگر نیاز داشته باشید تغییری در یک پرونده ایجاد کنید، اما کدگذاری پرونده را ندانید، چه کاری میتوانید انجام دهید؟ اگر میدانید کدگذاری آن با ASCII سازگار است و فقط میخواهید بخشهای ASCII را بررسی یا تغییر دهید، میتوانید پرونده را با هندلر خطای ``surrogateescape`` باز کنید::"
msgid ""
"with open(fname, 'r', encoding=\"ascii\", errors=\"surrogateescape\") as f:\n"
" data = f.read()\n"
"\n"
"# make changes to the string 'data'\n"
"\n"
"with open(fname + '.new', 'w',\n"
" encoding=\"ascii\", errors=\"surrogateescape\") as f:\n"
" f.write(data)"
msgstr ""
"with open(fname, 'r', encoding=\"ascii\", errors=\"surrogateescape\") as f:\n"
" data = f.read()\n"
"\n"
"# make changes to the string 'data'\n"
"\n"
"with open(fname + '.new', 'w',\n"
" encoding=\"ascii\", errors=\"surrogateescape\") as f:\n"
" f.write(data)"
msgid "The ``surrogateescape`` error handler will decode any non-ASCII bytes as code points in a special range running from U+DC80 to U+DCFF. These code points will then turn back into the same bytes when the ``surrogateescape`` error handler is used to encode the data and write it back out."
msgstr "هندلر خطای ``surrogateescape`` هر بایت غیر ASCII را بهصورت نقاط کد در بازهای خاص از U+DC80 تا U+DCFF کدگشایی میکند. سپس وقتی از هندلر خطای ``surrogateescape`` برای کدگذاری داده و نوشتن مجدد آن استفاده شود، این نقاط کد به همان بایتها تبدیل میشوند."
msgid "One section of `Mastering Python 3 Input/Output <https://pyvideo.org/video/289/pycon-2010--mastering-python-3-i-o>`_, a PyCon 2010 talk by David Beazley, discusses text processing and binary data handling."
msgstr "بخشی از `Mastering Python 3 Input/Output <https://pyvideo.org/video/289/pycon-2010--mastering-python-3-i-o>`_، یک سخنرانی PyCon 2010 از David Beazley، به پردازش متن و مدیریت دادههای دودویی میپردازد."
msgid "The `PDF slides for Marc-André Lemburg's presentation \"Writing Unicode-aware Applications in Python\" <https://downloads.egenix.com/python/LSM2005-Developing-Unicode-aware-applications-in-Python.pdf>`_ discuss questions of character encodings as well as how to internationalize and localize an application. These slides cover Python 2.x only."
msgstr "`اسلایدهای PDF مربوط به ارائه مارک-آندره لمبورگ با عنوان \"Writing Unicode-aware Applications in Python\" <https://downloads.egenix.com/python/LSM2005-Developing-Unicode-aware-applications-in-Python.pdf>`_ به بررسی مسائل کدگذاری نویسهها و همچنین چگونگی بینالمللیسازی و بومیسازی یک برنامه میپردازد. این اسلایدها تنها پایتون 2.x را پوشش میدهند."
msgid "`The Guts of Unicode in Python <https://pyvideo.org/video/1768/the-guts-of-unicode-in-python>`_ is a PyCon 2013 talk by Benjamin Peterson that discusses the internal Unicode representation in Python 3.3."
msgstr "`The Guts of Unicode in Python <https://pyvideo.org/video/1768/the-guts-of-unicode-in-python>`_ یک سخنرانی در PyCon 2013 از بنجامین پترسون است که به بررسی بازنمایی داخلی یونیکد در پایتون 3.3 میپردازد."
msgid "Acknowledgements"
msgstr "قدردانیها"
msgid "The initial draft of this document was written by Andrew Kuchling. It has since been revised further by Alexander Belopolsky, Georg Brandl, Andrew Kuchling, and Ezio Melotti."
msgstr "پیشنویس اولیه این سند توسط Andrew Kuchling نوشته شد. از آن زمان تاکنون، این سند توسط Alexander Belopolsky، Georg Brandl، Andrew Kuchling و Ezio Melotti بیشتر بازبینی شده است."
msgid "Thanks to the following people who have noted errors or offered suggestions on this article: Éric Araujo, Nicholas Bastin, Nick Coghlan, Marius Gedminas, Kent Johnson, Ken Krugler, Marc-André Lemburg, Martin von Löwis, Terry J. Reedy, Serhiy Storchaka, Eryk Sun, Chad Whitacre, Graham Wideman."
msgstr "با تشکر از افراد زیر که به خطاهای این مقاله اشاره کرده یا پیشنهادهایی درباره آن ارائه کردهاند: Éric Araujo، Nicholas Bastin، Nick Coghlan، Marius Gedminas، Kent Johnson، Ken Krugler، Marc-André Lemburg، Martin von Löwis، Terry J. Reedy، Serhiy Storchaka، Eryk Sun، Chad Whitacre و Graham Wideman."