Chapterبەش 4 · Lectureوانە 4.3
ASCII and Character CodesASCII و کۆدەکانی نووسە
How a computer stores text as bit patterns: how many bits a code needs, packing characters into words, the 7-bit ASCII code and its groups, a corrected ASCII chart, encoding and decoding exercises, the parity bit and error-correcting codes, older codes (Baudot, 6-bit BCD, EBCDIC) and Unicode with UTF-8 today.
چۆن دەق وەک کۆمەڵە هەڵدەگرێت: کۆدێک پێویستی بە چەند هەیە، خستنی چەند لە یەک ، کۆدی حەوت بیتیی و گرووپەکانی، خشتەیەکی ڕاستکراوەی ، ڕاهێنانی کۆدکردن و خوێندنەوەی کۆد، و کۆدە ڕاستکەرەوەکانی هەڵە، کۆدە کۆنەکان (Baudot، BCDـی شەش بیتی و ) و لەگەڵ UTF-8 ئەمڕۆ.
What you will learnچی فێر دەبیت
- Explain why N bits give different characters and how characters are packed into words.
- Name the groups of the 128 ASCII codes and find any character in the ASCII chart.
- Encode text as ASCII codes (decimal, hex and binary) and decode ASCII bit patterns back into text.
- Add an even or odd parity bit and say what it can and cannot detect.
- Explain how Unicode and UTF-8 extend ASCII to every writing system, Kurdish included.
- ڕوونی بکەیتەوە بۆچی N جیاواز دەدات و چۆن لە کۆ دەکرێنەوە.
- گرووپەکانی 128 کۆدەکەی بناسیت و هەر لە خشتەی بدۆزیتەوە.
- دەق بکەیت بە کۆدی (، و ) و کۆمەڵە بیتی بخوێنیتەوە و بیکەیتەوە بە دەق.
- جووت یان تاک زیاد بکەیت و بڵێیت چی دەدۆزێتەوە و چی نادۆزێتەوە.
- ڕوونی بکەیتەوە و UTF-8 چۆن بۆ هەموو جۆرە نووسینێک فراوان دەکەن، کوردیشی لەگەڵدا.
Text is stored as bit patternsدەق وەک کۆمەڵە بیت هەڵدەگیرێت
Computers do not only store numbers. A program's code, the names in a shop's customer list, an algebraic expression such as in a maths program, a text message and a study that counts the words in a book are all text. To store text, the computer gives every — a letter, a digit, a punctuation mark, even a space — its own pattern of bits.
تەنها ژمارە هەڵناگرن. کۆدی ، ناوی کڕیارانی دووکانێک، وەک لە بیرکاریدا، نامەیەک لە مۆبایلدا و لێکۆڵینەوەیەک کە وشەکانی کتێبێک دەژمێرێت هەموویان دەقن. بۆ هەڵگرتنی دەق، بە هەر — پیتێک، ، نیشانەیەکی خاڵبەندی، تەنانەت — کۆمەڵە بیتێکی تایبەتی خۆی دەدات.
How many bits does each character need? That depends on how many different characters the code must hold. With N bits there are different patterns (see how many patterns N bits give), so each extra bit doubles the number of characters.
هەر پێویستی بە چەند هەیە؟ ئەمە بەندە بەوەی کۆدەکە دەبێت چەند جیاواز هەڵبگرێت. بە N ، کۆمەڵەی جیاواز هەیە (بڕوانە N بیت چەند کۆمەڵە دەدات)، بۆیە هەر بیتێکی زیادە ژمارەی دوو هێندە دەکات.
| Bits | Patternsکۆمەڵەکان | Enough forبەس دەکات بۆ |
|---|---|---|
| 6 | Capital letters, digits and a few signs — no small lettersپیتە گەورەکان، و چەند نیشانەیەک — بێ پیتە بچووکەکان | |
| 7 | Capital and small letters, digits, signs and control codes (ASCII)پیتە گەورە و بچووکەکان، ، نیشانەکان و کۆدەکانی کۆنترۆڵ () | |
| 8 | Everything in ASCII plus 128 more charactersهەموو لەگەڵ 128 زیاتر |
A school gives each pupil a locker with a number. Two-digit numbers are enough for 100 pupils; a bigger school needs three digits. A character code works the same way: the more characters you want, the more bits each code needs.
قوتابخانەیەک دۆڵابێکی ژمارەدار دەدات بە هەر قوتابییەک. ژمارەی دوو بۆ 100 قوتابی بەسە؛ قوتابخانەیەکی گەورەتر پێویستی بە سێ هەیە. کۆدی بەهەمان شێوە کار دەکات: تا زیاترت بوێت، هەر کۆدێک پێویستی بە زیاتر دەبێت.
Where the analogy stops workingسنووری ئەم نموونەیە
Locker numbers are decimal, so one more digit gives ten times as many numbers. Codes are binary, so one more bit only doubles them.
ژمارەی دۆڵابەکان ، بۆیە یەک زیاتر دە هێندە ژمارە دەدات. کۆدەکان ، بۆیە یەک زیاتر تەنها دوو هێندەیان دەکات.
Text is stored as bit patternsدەق وەک کۆمەڵە بیت هەڵدەگیرێت
Packing characters into wordsخستنی نووسەکان لە وشەکاندا
A computer moves data in Words: fixed groups of bits that it handles in one step, for example 32 or 64 bits. If a word is much longer than a character, keeping only one character in each word wastes most of the word. So several characters are packed into one word: a 32-bit word holds four 8-bit characters.
بە وشەکان دەگوازێتەوە: کۆمەڵە بیتێکی جێگیر کە بە یەک هەنگاو کاری لەسەر دەکات، بۆ نموونە 32 یان 64 . ئەگەر زۆر لە درێژتر بێت، دانانی تەنها یەک لە هەر زۆربەی ئەو بە فیڕۆ دەدات. بۆیە چەند پێکەوە دەخرێنە یەک : 32 بیتی چوار هەشت بیتی هەڵدەگرێت.
Why did computers settle on 8 bits? A modern computer needs capital letters, small letters, ten digits and many signs — far more than 64, so 6 bits are too few. Seven bits are enough (128), but 7 is an awkward size for a machine built around powers of two. So the 8-bit became the standard home for one character.
بۆچی هەشت هەڵبژارد؟ نوێ پێویستی بە پیتە گەورەکان، پیتە بچووکەکان، دە و زۆر نیشانە هەیە — زۆر لە 64 زیاتر، بۆیە شەش کەمە. حەوت بەسە (128)، بەڵام 7 قەبارەیەکی نالەبارە بۆ ئامێرێک کە لەسەر توانەکانی 2 دروست کراوە. بۆیە هەشت بیتی بوو بە شوێنی ستانداردی یەک .
An old computer uses 6-bit characters and a word length of 36 bits. How many characters can be packed into one word?
کۆن شەش بیتی بەکار دەهێنێت و درێژیی 36 . چەند دەخرێنە یەک ؟
Show answerوەڵامەکە پیشان بدە
Six characters fit exactly, with no bits left over.
شەش بە تەواوی جێیان دەبێتەوە و هیچ بیتێک نامێنێتەوە.
ASCII: one code for every machineASCII: یەک کۆد بۆ هەموو ئامێرێک
An old standard code that gives every English letter, digit and common symbol a number from 0 to 127, written with 7 . A computer usually keeps each ASCII in one . Today's UTF-8 keeps the same codes and adds every other alphabet, including Kurdish.
کۆدێکی ستانداردی کۆنە کە ژمارەیەک لە 0 تا 127 دەدات بە هەر پیتێکی ئینگلیزی، هەر ژمارەیەک و هەر هێمایەکی باو. ئەم ژمارانە بە ٧ دەنووسرێن و بە زۆری هەر ASCII لە یەک هەڵدەگرێت. ئەمڕۆ UTF-8 هەمان کۆدەکان دەپارێزێت و هەموو ئەلفوبێکانی تریش زیاد دەکات، لەوانە کوردی.
ASCII stands for American Standard Code for Information Interchange. It was first published in 1963 and revised in 1967 and 1986. Its job is agreement: if every computer, terminal and printer uses the same number for the same character, text can travel between them without turning into nonsense. It was accepted almost everywhere, and most computers and electronic devices still understand it.
کورتکراوەی American Standard Code for Information Interchangeـە (کۆدی ستانداردی ئەمریکی بۆ ئاڵوگۆڕی زانیاری). یەکەمجار لە 1963 بڵاوکرایەوە و لە 1967 و 1986 نوێ کرایەوە. ئەرکەکەی ڕێککەوتنە: ئەگەر هەموو ، تێرمیناڵ و هەمان ژمارە بۆ هەمان بەکار بهێنن، دەق بەبێ تێکچوون لە نێوانیاندا دەگوازرێتەوە. نزیکەی لە هەموو شوێنێک وەرگیرا و زۆربەی و ئامێرە ئەلیکترۆنییەکان هێشتا تێیدەگەن.
ASCII: one code for every machineASCII: یەک کۆد بۆ هەموو ئامێرێک
Seven bits, kept in a byteحەوت بیت، لە بایتێکدا
Original ASCII uses 7 bits for each character, so it has 128 codes, numbered 0 to 127. A computer keeps each ASCII character in one 8-bit : the 7 code bits plus one extra bit on the left. For plain ASCII text that extra bit is 0, so the byte for A (code 65) is 01000001.
سەرەتایی بۆ هەر حەوت بەکار دەهێنێت، بۆیە 128 کۆدی هەیە، لە 0 تا 127. هەر لە یەک هەشت بیتیدا هەڵدەگرێت: حەوت بیتەکەی کۆد لەگەڵ یەک بیتی زیادە لە لای چەپ. بۆ دەقی ئاسایی ئەو بیتە زیادەیە 0ـە، بۆیە A (کۆدی 65) دەبێتە 01000001.
ASCII: one code for every machineASCII: یەک کۆد بۆ هەموو ئامێرێک
The groups inside ASCIIگرووپەکانی ناو ASCII
The 128 codes are not mixed up at random. They come in neat groups, and knowing the groups makes the chart easy to use.
128 کۆدەکە بە هەڕەمەکی تێکەڵ نین. لە گرووپی ڕێکدان. ناسینی گرووپەکان بەکارهێنانی خشتەکە ئاسان دەکات.
| Codes (decimal)کۆدەکان () | Groupگرووپ | What they areچین |
|---|---|---|
| 0–31, 127 | Control characters (33) (33) | Not printable. They tell a device to do something: start a new line, move to the next tab stop, beep.چاپ ناکرێن. بە ئامێرێک دەڵێن کارێک بکات: دێڕێکی نوێ دەست پێ بکات، بچێتە خاڵی تابی دواتر، دەنگ بدات. |
| 32 | Space (1) (1) | The gap between words. It prints no mark but takes a place, so it counts as a printable character.بۆشایی نێوان وشەکان. هیچ نیشانەیەک چاپ ناکات بەڵام شوێنێک دەگرێت، بۆیە بە چاپکراو دادەنرێت. |
| 33–47, 58–64, 91–96, 123–126 | Symbols (32) (32) | Printable, but neither letters nor digits: punctuation, maths and technical signs.چاپ دەکرێن، بەڵام نە پیتن نە : نیشانەکانی خاڵبەندی، بیرکاری و تەکنیکی. |
| 48–57 | Digits (10) (10) | The ten digits 0 to 9.دە 0 تا 9. |
| 65–90 | Capital letters (26)پیتە گەورەکان (26) | A to Z.A تا Z. |
| 97–122 | Small letters (26)پیتە بچووکەکان (26) | a to z.a تا z. |
Check the total: — 33 control codes and 95 printable characters (the space, 32 symbols, 10 digits and 52 letters).
کۆکەی بپشکنە: — 33 کۆدی کۆنترۆڵ و 95 چاپکراو (، 32 ، 10 و 52 پیت).
The ASCII chart, correctedخشتەی ASCII، ڕاستکراوە
The chart below shows all 128 codes as 8 rows of 16. The row is the first digit (the left 3 bits of the code) and the column is the second hex digit (the right 4 bits). So the hex code is simply “row digit, then column digit”, and the decimal code is . The small number in each cell is the decimal code.
خشتەکەی خوارەوە هەموو 128 کۆدەکە وەک 8 ڕیز پیشان دەدات، هەر ڕیزێک 16 کۆد. ڕیز یەکەم (سێ چەپی کۆدەکە) و ستوون دووەمی (چوار ڕاست). کەواتە کۆدی تەنها « ڕیز، پاشان ستوون»ـە و کۆدی ـە. ژمارە بچووکەکەی ناو هەر خانەیەک کۆدە .
The handout draws the same 128 codes as 16 rows of 8 (bits 3–6 pick the row, bits 0–2 the column). The layout is different, but the codes are the same. In both charts a single character in a cell is printable, while a two- or three-letter name such as SP, BS or CR is a space or a control code.
بڵاوکراوەکە هەمان 128 کۆد وەک 16 ڕیز پیشان دەدات، هەر ڕیزێک هەشت کۆد ( 3–6 ڕیزەکە هەڵدەبژێرن و 0–2 ستوونەکە). شێوەکە جیاوازە، بەڵام کۆدەکان هەمانن. لە هەردوو خشتەکەدا تاک لە خانەیەکدا چاپ دەکرێت، بەڵام ناوێکی دوو یان سێ پیتی وەک SP، BS یان CR یان کۆدێکی کۆنترۆڵە.
The ASCII chart, correctedخشتەی ASCII، ڕاستکراوە
The course's tables, correctedخشتەکانی کۆرسەکە، ڕاستکراوە
The ASCII chart, correctedخشتەی ASCII، ڕاستکراوە
Control charactersنووسەکانی کۆنترۆڵ
A character code that does not print a symbol but tells a device to do something, such as start a new line. In ASCII the codes 0–31 and 127 are control characters.
کۆدی کە هیچ هێمایەک چاپ ناکات، بەڵکو بە ئامێرێک دەڵێت کارێک بکات، وەک دەستپێکردنی دێڕێکی نوێ. لە ASCIIـدا کۆدەکانی 0 تا 31 و 127 نووسەی کۆنترۆڵن.
Most control codes come from the teleprinter (Teletype), a typewriter-like machine that printed on paper and sent text down a wire. CR (carriage return) sent the print head back to the start of the line, and LF (line feed) moved the paper up one line. That is why a new line in a text file is still a control code: Windows ends lines with CR LF, while Linux and macOS use LF alone.
زۆربەی کۆدەکانی کۆنترۆڵ لە تێلێپرینتەر (Teletype)ـەوە هاتوون، ئامێرێکی وەک تایپ کە لەسەر کاغەز چاپی دەکرد و دەقی بە وایەردا دەنارد. CR (carriage return) سەری چاپەکەی دەگەڕاندەوە بۆ سەرەتای دێڕ و LF (line feed) کاغەزەکەی یەک دێڕ بەرز دەکردەوە. بۆیە دێڕی نوێ لە دەقیدا هێشتا کۆدێکی کۆنترۆڵە: Windows دێڕەکان بە CR LF کۆتایی پێ دەهێنێت، بەڵام Linux و macOS تەنها LF بەکار دەهێنن.
| Codeکۆد | Nameناو | What it doesچی دەکات |
|---|---|---|
| 0 | NUL | Null: “nothing”, used as filler.هیچ: بۆ پڕکردنەوە بەکار دێت. |
| 7 | BEL | Bell: asks for attention (a beep).زەنگ: داوای سەرنج دەکات (دەنگێک). |
| 8 | BS | Backspace: move back one place.گەڕانەوە: یەک شوێن بگەڕێوە دواوە. |
| 9 | HT | Horizontal tab: jump to the next tab stop (the Tab key).تابی ئاسۆیی: بازدان بۆ خاڵی تابی دواتر ( Tab). |
| 10 | LF | Line feed: go to the next line (old name NL).Line feed: بچۆ بۆ دێڕی دواتر (ناوی کۆن NL). |
| 12 | FF | Form feed: start a new page (old name NP).Form feed: لاپەڕەیەکی نوێ دەست پێ بکە (ناوی کۆن NP). |
| 13 | CR | Carriage return: go back to the start of the line.Carriage return: بگەڕێوە بۆ سەرەتای دێڕەکە. |
| 27 | ESC | Escape: the next few characters have a special meaning.Escape: چەند دواتر واتایەکی تایبەتیان هەیە. |
| 127 | DEL | Delete: on paper tape, punching all 7 holes erased a wrong character.سڕینەوە: لەسەر شریتی کاغەز، کونکردنی هەر حەوت کونەکە هەڵەی دەسڕییەوە. |
Clever patterns in the chartڕێکخستنی زیرەکانەی خشتەکە
ASCII was designed so that useful facts are hidden in the bits. Digits: 0 is 48 = 0110000 and 7 is 55 = 0110111. The right four bits of a digit's code are the digit's own value in binary, so subtracting 48 from the code gives the digit (). These four bits are exactly the digit's BCD code.
بەجۆرێک دیزاین کراوە کە زانیاریی بەسوود لە ناو شاراوەیە. : 0 48ـە = 0110000 و 7 55ـە = 0110111. چوار ڕاستی کۆدی هەر نرخی خودی ئەو بە ، بۆیە ئەگەر 48 لە کۆدەکە کەم بکەیتەوە دەمێنێتەوە (). ئەم چوار ڕێک کۆدی دەیی دووانیی ئەو .
Letters: A is 65 and a is 97. The difference is 32, which is a single bit: A = 1000001, a = 1100001. Every capital letter and its small letter differ only in that one bit, so changing case means flipping one bit.
پیتەکان: A 65ـە و a 97ـە. جیاوازییەکەیان 32ـە، کە تەنها یەک : A = 1000001، a = 1100001. هەموو پیتێکی گەورە و پیتە بچووکەکەی تەنها لەو یەک جیاوازن، بۆیە گۆڕینی گەورەیی و بچووکیی پیت واتە گۆڕینی یەک .
| Character | Decimal | Binary (7 bits) (7 ) |
|---|---|---|
0 | 48 | 011 0000 |
7 | 55 | 011 0111 |
9 | 57 | 011 1001 |
A | 65 | 100 0001 |
a | 97 | 110 0001 |
Z | 90 | 101 1010 |
z | 122 | 111 1010 |
Programs compare text by these codes. Because every capital letter (65–90) comes before every small letter (97–122), sorting by code puts “Zebra” before “apple”.
دەق بەپێی ئەم کۆدانە بەراورد دەکەن. چونکە هەموو پیتێکی گەورە (65–90) پێش هەموو پیتێکی بچووک (97–122) دێت، بەپێی کۆد «Zebra» پێش «apple» دادەنێت.
Reading ASCII text in binary by hand: 010 starts capitals, 011 starts small letters, and the last five bits give the alphabet position.
خوێندنەوەی دەقی بە بە دەست: 010 سەرەتای پیتە گەورەکانە، 011 سەرەتای پیتە بچووکەکان و پێنج کۆتایی شوێنی پیتەکە لە ئەلفوبێدا دەدەن.
Whole video (3:29).
هەموو ڤیدیۆکە (3:29).
From text to bits and backلە دەقەوە بۆ بیتەکان و بە پێچەوانەوە
- Encode: find each codeکۆدکردن: کۆدی هەر یەکێک بدۆزەوە
Look up each character (spaces and punctuation too) in the chart and write its decimal or hex code.
هەر (بۆشایی و نیشانەکانی خاڵبەندیش) لە خشتەکەدا بدۆزەوە و کۆدە یان بنووسە.
- Encode: convert to binaryکۆدکردن: بیگۆڕە بۆ دووانی
Write each code in 7 bits (or 8 bits with a 0 in front for a byte). Hex is quickest: each hex digit becomes 4 bits.
هەر کۆدێک بە حەوت بنووسە (یان هەشت بە 0ـێک لە پێشەوە بۆ ). خێراترینە: هەر دەبێتە چوار .
- Decode: split, convert, look upخوێندنەوە: دابەشی بکە، بیگۆڕە، بیدۆزەوە
Split the bits into groups of 7 (or 8), turn each group into a decimal number, and find that number in the chart.
بکە بە گرووپی حەوتی (یان هەشتی)، هەر گرووپێک بگۆڕە بۆ ژمارەیەکی و ئەو ژمارەیە لە خشتەکەدا بدۆزەوە.
| Character | Decimal | Hex | Byte (8 bits) (8 ) |
|---|---|---|---|
h | 104 | 68 | 01101000 |
o | 111 | 6F | 01101111 |
p | 112 | 70 | 01110000 |
e | 101 | 65 | 01100101 |
Exercises from the courseڕاهێنانەکانی کۆرسەکە
Decode these ASCII-coded messages:
(a) 1001001 1000001 1001101
(b) 1000011 1001111 1000100
(c) 1010011 1100101 1100011 1110100 1101001 1101111 1101110 0100000 0110010 0111011
ئەم نامانەی بە کۆدکراون بخوێنەرەوە:
(أ) 1001001 1000001 1001101
(ب) 1000011 1001111 1000100
(ج) 1010011 1100101 1100011 1110100 1101001 1101111 1101110 0100000 0110010 0111011
Hintئاماژە
Turn each 7-bit group into decimal first, then use the chart.
سەرەتا هەر گرووپێکی حەوت بیتی بگۆڕە بۆ ، پاشان خشتەکە بەکار بهێنە.
Show answerوەڵامەکە پیشان بدە
| Messageنامە | Decimal codesکۆدەکان بە | Textدەق |
|---|---|---|
| (a)(أ) | 73 65 77 | IAM |
| (b)(ب) | 67 79 68 | COD |
| (c)(ج) | 83 101 99 116 105 111 110 32 50 59 | Section 2; |
In message (c), code 32 is a space, 50 is the digit 2 (not the number two) and 59 is a semicolon.
لە نامەی (ج)دا کۆدی 32 ، 50 2ـە (نەک ژمارەی دوو) و 59 .
Write the ASCII codes of these two program statements in hexadecimal and in binary:
(a) 80 INPUT Y
(b) 30 INPUT A, B
They are lines of an old BASIC program: a line number, then a statement that asks the user to type values into the variables. Every space and the comma are characters too.
کۆدەکانی ئەم دوو بە و بە بنووسە:
(أ) 80 INPUT Y
(ب) 30 INPUT A, B
ئەمانە دێڕی کۆنی BASICـن: ژمارەی دێڕ، پاشان کە داوا لە بەکارهێنەر دەکات نرخ بۆ گۆڕاوەکان بنووسێت. هەموو و کۆماکەش (,) .
Show answerوەڵامەکە پیشان بدە
char: 8 0 SP I N P U T SP Y
hex: 38 30 20 49 4E 50 55 54 20 59
bin: 0111000 0110000 0100000 1001001 1001110 1010000 1010101 1010100 0100000 1011001char: 3 0 SP I N P U T SP A , SP B
hex: 33 30 20 49 4E 50 55 54 20 41 2C 20 42
bin: 0110011 0110000 0100000 1001001 1001110 1010000 1010101 1010100 0100000 1000001 0101100 0100000 1000010Hex to binary is quick: each hex digit is 4 bits, for example 4E is 0100 1110, which as 7 bits is 1001110. Notice that the digits 8, 0 and 3 are characters 38, 30 and 33 hex, not the numbers 8, 0 and 3.
گۆڕینی بۆ خێرایە: هەر چوار ، بۆ نموونە 4E دەبێتە 0100 1110 و بە حەوت دەبێتە 1001110. سەرنج بدە کە 8، 0 و 3 38، 30 و 33ی ، نەک ژمارەکانی 8، 0 و 3.
The following message is encoded in ASCII. What is the message?
1000111 1001111 1010100 1001111 0100000 1001110 0110100 0110111
ئەم نامەیەی خوارەوە بە کۆد کراوە. نامەکە چییە؟
1000111 1001111 1010100 1001111 0100000 1001110 0110100 0110111
Show answerوەڵامەکە پیشان بدە
| Bits | Decimal | Character |
|---|---|---|
1000111 | 71 | G |
1001111 | 79 | O |
1010100 | 84 | T |
1001111 | 79 | O |
0100000 | 32 | space |
1001110 | 78 | N |
0110100 | 52 | 4 |
0110111 | 55 | 7 |
The message is GOTO N47. None of these codes needed the two wrong entries of the exam's printed table, but check any table before you trust it.
نامەکە GOTO N47ـە. هیچ کام لەم کۆدانە پێویستی بە دوو هەڵەکەی خشتە چاپکراوەکەی تاقیکردنەوەکە نەبوو، بەڵام پێش متمانەکردن بە هەر خشتەیەک بیپشکنە.
Write the name Lana as four hex codes.
ناوی Lana وەک چوار کۆدی بنووسە.
Hintئاماژە
Capital L is row 4; small letters are in rows 6 and 7.
Lـی گەورە لە ڕیزی 4ـدایە؛ پیتە بچووکەکان لە ڕیزەکانی 6 و 7ـدان.
Show answerوەڵامەکە پیشان بدە
L = 4C, a = 61, n = 6E, a = 61, so the name is 4C 61 6E 61 (decimal 76 97 110 97).
L = 4C، a = 61، n = 6E، a = 61، کەواتە ناوەکە دەبێتە 4C 61 6E 61 (: 76 97 110 97).
The parity bit: a simple checkبیتی پاریتی: پشکنینێکی سادە
When a byte travels along a wire, electrical noise can flip a bit from 0 to 1 or from 1 to 0. A cheap way to notice this is a : the sender adds one extra bit so that the number of 1s in the byte is always even (even parity) or always odd (odd parity). The receiver counts the 1s. If the count is wrong, a bit has changed on the way.
کاتێک بە وایەرێکدا دەڕوات، ژاوەژاو دەتوانێت لە 0ـەوە بکات بە 1 یان لە 1ـەوە بکات بە 0. ڕێگایەکی هەرزان بۆ هەستکردن بەمە ـە: نێرەرەکە یەک زیادە دادەنێت بۆ ئەوەی ژمارەی 1ـەکانی ناو هەمیشە جووت بێت (پاریتیی جووت) یان هەمیشە تاک بێت (پاریتیی تاک). وەرگرەکە 1ـەکان دەژمێرێت. ئەگەر ژمارەکە هەڵە بێت، لە ڕێگادا گۆڕاوە.


| Character | 7-bit codeکۆدی حەوت بیتی | Number of 1sژمارەی 1ـەکان | Even parity byte بە پاریتیی جووت | Odd parity byte بە پاریتیی تاک |
|---|---|---|---|---|
O | 1001111 | 5 | 11001111 | 01001111 |
K | 1001011 | 4 | 01001011 | 11001011 |
How one parity bit catches a bit flipped on a wire, and how XOR gates compute parity, using ASCII text such as "hello world".
یەک چۆن دەدۆزێتەوە کە لەسەر وایەرێک پێچەوانە بووەتەوە، هەروەها چۆن هەژمار دەکەن، بە نموونەی دەقی وەک «hello world».
Plays 0:00-7:37: transmission errors, redundancy, the parity idea and the XOR parity circuit; the rest builds and tests hardware.
لە 0:00 تا 7:37 پەخش دەبێت: هەڵەکانی گواستنەوە، زیادە بۆ پشکنین، بیرۆکەی و بە XOR؛ باقی ڤیدیۆکە ڕاستەقینە دروست دەکات و تاقی دەکاتەوە.
The parity bit: a simple checkبیتی پاریتی: پشکنینێکی سادە
What one parity bit can and cannot doیەک بیتی پاریتی چی دەتوانێت و چی ناتوانێت
One parity bit catches any single flipped bit (in fact any odd number of flips). Two flipped bits cancel each other out and pass unseen, and the receiver cannot tell which bit is wrong, so the byte must be sent again. Old serial links commonly sent 7 data bits plus a parity bit; today networks and disks use stronger checks, such as CRC codes, that catch far more errors.
یەک هەر یەک گۆڕاو دەگرێت (لە ڕاستیدا هەر ژمارەیەکی تاکی گۆڕان). دوو گۆڕاو یەکتر پووچ دەکەنەوە و نابینرێن. هەروەها وەرگرەکە ناتوانێت بزانێت کام هەڵەیە، بۆیە دەبێت دووبارە بنێردرێتەوە. هێڵە زنجیرەییە کۆنەکان زۆرجار حەوت لەگەڵ دەنارد؛ ئەمڕۆ و دیسکەکان پشکنینی بەهێزتر وەک کۆدەکانی CRC بەکار دەهێنن کە زۆر هەڵەی زیاتر دەگرن.
Some error codes go further and correct the error. A Hamming code (Richard Hamming, 1950) adds several check bits, each one checking a different group of data bits, so the receiver can work out which bit flipped and flip it back. The ECC memory of servers uses this idea to fix single-bit errors on its own.
هەندێک کۆدی هەڵە زیاتر دەڕۆن و هەڵەکە ڕاست دەکەنەوە. کۆدی Hamming (ڕیچارد هامینگ، 1950) چەند پشکنین زیاد دەکات کە هەر یەکێکیان گرووپێکی جیاوازی دەپشکنێت، بۆیە وەرگرەکە دەتوانێت بزانێت کام گۆڕاوە و بیگەڕێنێتەوە. ECCـی ڕاژەکارەکان ئەم بیرۆکەیە بەکار دەهێنێت بۆ ئەوەی هەڵەی یەک خۆی ڕاست بکاتەوە.
Older codes: Baudot and 6-bit BCDکۆدە کۆنەکان: Baudot و BCDـی شەش بیتی
The oldest code in this story is the Baudot code of the 1870s, made for the telegraph. It used only 5 bits, so it had just patterns — too few for letters and digits together. Two special codes, letters and figures, switched the meaning of the codes after them, a little like the Shift key. An improved version (ITA2, 1932) ran the world's teleprinters for decades.
کۆنترین کۆدی ئەم چیرۆکە کۆدی Baudotـە لە ساڵانی 1870دا، کە بۆ تەلەگراف دروست کرا. تەنها پێنج بەکار دەهێنا، بۆیە تەنها کۆمەڵەی هەبوو — بۆ پیت و پێکەوە زۆر کەم بوو. دوو کۆدی تایبەت، پیتەکان و ژمارەکان، واتای ئەو کۆدانەیان دەگۆڕی کە دوایان دەهاتن، کەمێک وەک Shift. وەشانێکی باشترکراو (ITA2، 1932) بۆ چەندین دەیە تێلێپرینتەرەکانی جیهانی بەڕێوە دەبرد.
Before ASCII, many computers used a 6-bit BCD character code with 48 characters: the 26 capital letters, the ten digits 0–9 and twelve special characters (+ - * / , . ( ) $ = ' and the space). With small differences it was the standard of many machines and appeared in many computer manuals. Notice what is missing: there are no small letters.
پێش ، زۆر کۆدی شەش بیتیی BCDـی بەکار دەهێنا کە 48 بوو: 26 پیتە گەورەکە، دە 0–9 و دوازدە تایبەت (+ - * / , . ( ) $ = ' و ). بە جیاوازیی کەمەوە ستانداردی زۆر ئامێر بوو و لە زۆر ڕێنمایی دەرکەوت. سەرنج بدە چی نییە: هیچ پیتێکی بچووک نییە.
Older codes: Baudot and 6-bit BCDکۆدە کۆنەکان: Baudot و BCDـی شەش بیتی
EBCDIC, and the codes in one tableEBCDIC و کۆدەکان لە یەک خشتەدا
EBCDIC (Extended BCD Interchange Code) grew out of that BCD code at IBM in the 1960s. It is an 8-bit code that adds small letters and many more special characters. Some IBM mainframes still use it; almost every other computer uses ASCII and Unicode.
(Extended BCD Interchange Code) لە IBM لە ساڵانی 1960دا لەو کۆدە BCDـیەوە سەری هەڵدا. کۆدێکی هەشت بیتییە کە پیتە بچووکەکان و زۆر تایبەتی تر زیاد دەکات. هەندێک IBM هێشتا بەکاری دەهێنن؛ نزیکەی هەموو تر و بەکار دەهێنن.
| Codeکۆد | Bits | Patternsکۆمەڵەکان | Used forبۆ چی |
|---|---|---|---|
| Baudot / ITA2 | 5 | telegraph and teleprinters (1870s–1970s)تەلەگراف و تێلێپرینتەر (1870 تا 1970) | |
| 6-bit BCDBCDـی شەش بیتی | 6 | early computers (1950s–60s), capitals onlyیەکەم (ساڵانی 1950 و 1960)، تەنها پیتی گەورە | |
| ASCII | 7 | almost every computer since the 1960sنزیکەی هەموو لە ساڵانی 1960ـەوە | |
| EBCDIC | 8 | IBM mainframes IBM | |
| Unicode in UTF-8 بە UTF-8 | 8 to 32 (1 to 4 bytes)8 تا 32 (1 تا 4 ) | over 1.1 million code pointsزیاتر لە 1.1 ملیۆن | the web and phones today, Kurdish includedوێب و مۆبایل ئەمڕۆ، کوردیشی لەگەڵدا |
Unicode and UTF-8: ASCII todayUnicode و UTF-8: ASCII لە ئەمڕۆدا
ASCII has English letters only. There is no room for Kurdish letters such as ڕ, ڵ, ۆ and ێ, nor for Arabic, Chinese or emoji. For years each region used its own 8-bit code, and text often turned into nonsense when it moved between computers. fixed this with one list of every character of every writing system. Each character gets a number called a , written as U+ and hex: A is U+0041 and ڕ is U+0695. There is room for over 1.1 million code points (U+0000 to U+10FFFF).
تەنها پیتی ئینگلیزیی تێدایە. شوێنی نییە بۆ پیتە کوردییەکانی وەک ڕ، ڵ، ۆ و ێ، نە بۆ عەرەبی، چینی یان . بۆ چەندین ساڵ هەر ناوچەیەک کۆدێکی هەشت بیتیی تایبەتی خۆی بەکار دەهێنا و دەق زۆرجار کاتێک لە دەچووە تر تێک دەچوو. ئەمەی چارەسەر کرد بە یەک لیست بۆ هەموو هەموو سیستەمێکی نووسین. هەر ژمارەیەک وەردەگرێت کە پێی دەوترێت ، بە U+ و دەنووسرێت: A U+0041ـە و ڕ U+0695ـە. شوێن هەیە بۆ زیاتر لە 1.1 ملیۆن (U+0000 تا U+10FFFF).
Unicode and UTF-8: ASCII todayUnicode و UTF-8: ASCII لە ئەمڕۆدا
UTF-8: one to four bytesUTF-8: یەک تا چوار بایت
The first 128 code points of Unicode are exactly ASCII. UTF-8, the used by almost every web page today, stores each code point in 1 to 4 bytes. An ASCII character still takes one byte with the same value, so every ASCII file is already a valid UTF-8 file. Bytes of the longer characters always start with a 1 bit, so they can never be mistaken for ASCII.
یەکەم 128 ڕێک . UTF-8، ئەو نزیکەی هەموو ئەمڕۆ بەکاری دەهێنن، هەر لە 1 تا 4 هەڵدەگرێت. هێشتا یەک بە هەمان نرخ دەگرێت، بۆیە هەر خۆی دروستی UTF-8ـە. درێژترەکان هەمیشە بە 1 دەست پێ دەکەن، بۆیە هەرگیز لەگەڵ تێکەڵ نابن.
So a Kurdish word takes more bytes than an English word of the same length: Kurd is 4 bytes but کورد is 8. The Database Administration course counts bytes of Kurdish names in Kurdish letters in UTF-8.
بۆیە وشەیەکی کوردی زیاتر دەگرێت لە وشەیەکی ئینگلیزیی بە هەمان درێژی: Kurd چوار بەڵام کورد هەشتە. کۆرسی بەڕێوەبردنی ناوە کوردییەکان دەژمێرێت لە پیتە کوردییەکان لە UTF-8ـدا.
How Unicode gives every character a number and how UTF-8 stores it in one to four bytes while plain ASCII stays unchanged.
چۆن دەداتە هەموو و UTF-8 چۆن لە یەک تا چوار هەڵیدەگرێت، بە شێوەیەک کە ئاسایی وەک خۆی دەمێنێتەوە.
Plays 0:00-8:39 and stops before the Audible advert.
لە 0:00 تا 8:39 پەخش دەبێت و پێش ڕیکلامی Audible ڕادەوەستێت.
Unicode and UTF-8: ASCII todayUnicode و UTF-8: ASCII لە ئەمڕۆدا
Your turn: Kurdish in Unicodeنۆرەی تۆیە: کوردی لە Unicodeـدا
The word «کورد» has four letters: ک, و, ر and د. (a) Write the Unicode code point of each letter in hex and its UTF-8 bytes. (b) Why should Kurdish web pages be written in Unicode, and not with an old non-Unicode Kurdish font?
وشەی «کورد» چوار پیتی هەیە: ک، و، ر و د. (أ) هەر پیتێک بە و UTF-8ـی بنووسە. (ب) بۆچی دەبێت کوردی بە بنووسرێن، نەک بە کوردیی کۆنی نا-Unicode؟
Hintئاماژە
All four letters lie between U+0080 and U+07FF, so each takes two bytes: 110xxxxx 10xxxxxx. In Python, ord('ک') gives the code point and 'ک'.encode() the bytes.
هەر چوار پیتەکە لە نێوان U+0080 و U+07FF دان، بۆیە هەر یەکێکیان دوو دەگرێت: 110xxxxx 10xxxxxx. لە Pythonـدا ord('ک') دەدات و 'ک'.encode() .
Show answerوەڵامەکە پیشان بدە
| Letterپیت | Code point | UTF-8 bytes (hex) UTF-8 () |
|---|---|---|
ک | U+06A9 | DA A9 |
و | U+0648 | D9 88 |
ر | U+0631 | D8 B1 |
د | U+062F | D8 AF |
How the bytes of ک are made: the 11 bits of the code point are split 5 + 6 and placed after the markers 110 and 10.
ک چۆن دروست دەبن: 11 دەکرێنە 5 و 6 و لە دوای نیشانەکانی 110 و 10 دادەنرێن.
(a) «کورد» is 4 code points and 8 bytes. (b) In Unicode the file stores the real Kurdish letters, so every phone and computer can show them with any Unicode font, search engines find the words, copy and paste keeps them, and screen readers can read them. Old non-Unicode fonts stored the codes of other letters and only drew them as Kurdish: without that exact font the reader sees nonsense, and search, sorting and spell checking see the wrong letters. To type Kurdish in Unicode, add the Central Kurdish (Sorani) keyboard in your system's language settings.
(أ) «کورد» چوار و هەشت . (ب) لە پیتە کوردییە ڕاستەقینەکان هەڵدەگرێت، بۆیە هەموو مۆبایل و دەتوانێت بە هەر پیشانیان بدات، وشەکان دەدۆزنەوە، کۆپی و پەیست دەیانپارێزێت و دەتوانن بیانخوێننەوە. کۆنی نا-Unicode کۆدی پیتی تری هەڵدەگرت و تەنها وەک کوردی دەیکێشان: بەبێ هەمان ، خوێنەر شتێکی بێواتا دەبینێت و گەڕان، و پشکنینی ڕێنووس پیتی هەڵە دەبینن. بۆ نووسینی کوردی بە ، کوردیی ناوەندی (سۆرانی) لە ڕێکخستنەکانی زمانی سیستەمەکەتدا زیاد بکە.
Common mistakesهەڵە باوەکان
| Mistakeهەڵە | Fixچارەسەر |
|---|---|
Writing the digit character 7 as 0000111.نووسینی 7 وەک 0000111. | The character 7 is code 55 = 0110111. 0000111 is the number seven, which in ASCII is the control code BEL. 7 کۆدی 55ـە = 0110111. 0000111 ژمارەی حەوتە کە لە کۆدی کۆنترۆڵی BELـە. |
| Mixing hex and decimal codes: “A = 41”.تێکەڵکردنی کۆدی و : «A = 41». | Say which base you mean: A is .بڵێ مەبەستت کام : A ـە. |
| Dropping the leading 0 when the question asks for 8 bits.فڕێدانی 0ـی پێشەوە کاتێک پرسیارەکە داوای هەشت دەکات. | In a byte, H is 01001000, not 1001000.لە ، H 01001000ـە نەک 1001000. |
| Forgetting spaces and punctuation when encoding.لەبیرکردنی بۆشایی و نیشانەکانی خاڵبەندی لە کاتی کۆدکردندا. | Every space is code 32 and every comma is 44; they take a byte like any letter.هەر کۆدی 32ـە و هەر کۆمایەک (,) 44ـە؛ وەک هەر پیتێک دەگرن. |
Trusting a printed table that says - = 95 or & = 37.متمانەکردن بە خشتەیەکی چاپکراو کە دەڵێت - = 95 یان & = 37. | 95 is _, 45 is -, 37 is %, 38 is &.95 _ـە، 45 -ـە، 37 %ـە، 38 &ـە. |
| Thinking ASCII contains Kurdish letters.وا بیرکردنەوە کە پیتی کوردیی تێدایە. | Kurdish letters are in Unicode and take 2 bytes each in UTF-8.پیتە کوردییەکان لە و هەر یەکێکیان لە UTF-8ـدا دوو دەگرێت. |
Summaryپوختە
- N bits give codes: 6 bits give , 7 bits , 8 bits . Several characters are packed into one word.
- ASCII is a 7-bit code (0–127) stored one character per byte: control codes 0–31 and 127, space 32, digits 48–57, A–Z 65–90, a–z 97–122, symbols in between.
- Hex code = row digit + column digit of the chart; capital and small letters differ by 32 (one bit).
- A parity bit makes the number of 1s even or odd; it catches one flipped bit but not two.
- 6-bit BCD and EBCDIC are older codes. Today text is Unicode, usually stored as UTF-8, which keeps ASCII as single bytes. Baudot (5 bits) came before them all, and error-correcting codes such as Hamming codes fix single bits.
- N کۆد دەدات: شەش ، حەوت و هەشت . چەند پێکەوە دەخرێنە یەک .
- کۆدێکی حەوت بیتییە (0–127) و هەر لە هەڵدەگیرێت: کۆنترۆڵ 0–31 و 127، 32، 48–57، A–Z 65–90، a–z 97–122، لە نێوانیاندا.
- کۆدی = ڕیز + ستوونی خشتەکە؛ پیتی گەورە و بچووک بە 32 جیاوازن (یەک ).
- ژمارەی 1ـەکان جووت یان تاک دەکات؛ یەک گۆڕاو دەگرێت بەڵام دووان نا.
- BCDـی شەش بیتی و کۆدی کۆنن. ئەمڕۆ دەق و بە زۆری وەک UTF-8 هەڵدەگیرێت کە وەک یەک دەهێڵێتەوە. Baudot (پێنج ) پێش هەموویان بوو و کۆدی ڕاستکەرەوەی هەڵەی وەک Hamming ڕاست دەکەنەوە.
What is the ASCII code of the space, in decimal and in hex?کۆدی ASCIIـی بۆشایی چییە، بە دەیی و بە شانزەیی؟
.
.
Decode 1000001 1010010 1000001 1001101.1000001 1010010 1000001 1001101 بخوێنەرەوە.
65 82 65 77 = ARAM.
کۆدەکان 65 82 65 77ن = ARAM.
Why can a 32-bit word hold four ASCII characters?بۆچی وشەیەکی 32 بیتی دەتوانێت چوار نووسەی ASCII هەڵبگرێت؟
Each character is kept in an 8-bit byte, and .
هەر لە هەشت بیتیدا هەڵدەگیرێت و .
Is every ASCII file a valid UTF-8 file?ئایا هەر فایلێکی ASCII فایلێکی دروستی UTF-8ـیشە؟
Yes. UTF-8 stores code points 0–127 as the same single bytes as ASCII.
بەڵێ. UTF-8 0–127 وەک هەمان یەک هەڵدەگرێت.
Videoڤیدیۆ
Watch a videoسەیری ڤیدیۆیەک بکە
A video that viewers liked a lot and praised in their comments, chosen for this lesson.ڤیدیۆیەک کە بینەران زۆریان پێ خۆش بووە و لە کۆمێنتەکانیاندا ستایشیان کردووە، بۆ ئەم وانەیە هەڵبژێردراوە.
What ASCII is, how characters become binary codes, why 7 or 8 bits are not enough for every language, and how Unicode fixes that.
چییە، چۆن دەبنە کۆدی ، بۆچی 7 یان 8 بۆ هەموو زمانێک بەس نییە و چۆن ئەمە چارەسەر دەکات.
0:00 intro; 1:31 ASCII in binary; 2:24 keyboard codes; 2:48 the problem; 3:17 Unicode; 3:54 recap; 4:49 test yourself.
0:00 پێشەکی؛ 1:31 بە ؛ 2:24 کۆدەکانی ؛ 2:48 گرفتەکە؛ 3:17 ؛ 3:54 پێداچوونەوە؛ 4:49 خۆت تاقی بکەرەوە.
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
Electricity Basics: Voltage, Current and Resistanceبنەماکانی کارەبا: ڤۆڵتیە، تەزوو و بەرگری
Related lecturesوانە پەیوەندیدارەکان
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
- RFC 20: ASCII format for Network Interchange (1969)
- RFC 3629: UTF-8, a transformation format of ISO 10646
- Python documentation: Unicode HOWTO
- Wikipedia: ASCII
- Wikipedia: Parity bit
- T. L. Floyd, Digital Fundamentals, 11th ed., §2-11 Digital codes and §2-12 Error codes (Pearson, 2015)
- Wikipedia: Baudot code
- Wikipedia: Hamming code
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.