Character codes — ASCII and Unicode
Diperkenalkan
21:52
Sistem Angka & Data
Foto ini. Lagu ini. Video ini. Nama Anda, pesan Anda, setiap file di setiap perangkat—di dalam komputer, semuanya hanyalah nol dan satu.…
Narasi bahasa Inggris · takarir bahasa Inggris dan 中文 yang dapat dipilih
Dalam pelajaran ini
| English | Makna |
|---|---|
| bits/bɪts/ | A binary digit, taking the value zero or one. |
| character/ˈkærɪktə/ | A text unit such as a letter, digit, punctuation mark or other symbol. |
| code page | A table that matches characters to numbers for a particular character set. |
| bytes | Units of eight bits used to store data in a computer. |
| Unicode/ˈjuːnɪkəʊd/ | |
| ASCII/ˈæski/ | |
| encoding/enˈkəʊdɪŋ/ | pengkodean |
| character set/ˈkærɪktə set/ | himpunan karakter |
| binary code | A sequence of zeros and ones used to represent information. |
| code point/kəʊd pɔɪnt/ | titik kode |
| control codes | Codes that give instructions for handling text instead of representing visible characters. |
| carriage return | A control code that moves the position for writing text to the start of a line. |
| Extended ASCII | A group of character codes that use eight bits to represent characters. |
| UTF-8/ˌjuː tiː ˈef eɪt/ | |
| UTF-16 | A way to store Unicode characters using two or four bytes each. |
| UTF-32 | A way to store Unicode characters using four bytes each. |
| binary/ˈbaɪnəri/ | A number system using base two, with the digits zero and one. |
Email yang tiba sebagai kode acak
- Sepanjang dekade 1990-an, pesan yang diketik di Warsawa dan dibaca di Tokyo sering tiba seperti tumpukan omong kosong. Kedua komputer menyimpan delapan bit per karakter. Mereka sekadar tidak sepakat tentang makna 128 pola atas tersebut.
- Kode halaman Polandia menempatkan huruf-huruf Polandia di sana. Jepang menempatkannya dengan karakternya sendiri. Tidak ada yang rusak selama transmisi: byte-byte itu tiba utuh dan dibaca berdasarkan tabel yang berbeda.
- Solusinya adalah berhenti menggunakan tabel per negara dan memberikan setiap karakter dalam setiap aksara satu nomor, selamanya. Itulah Unicode, dan itulah alasan emoji yang Anda kirim tiba sebagai gambar yang sama.
- Pelajaran ini menjelaskan bagaimana teks berubah menjadi angka: himpunan karakter, ASCII, Unicode, dan pengkodean yang menyimpannya.

Himpunan karakter memberi setiap karakter sebuah nomor
- Komputer tidak menyimpan huruf, hanya angka. Himpunan karakter adalah kumpulan karakter yang dapat direpresentasikan komputer, masing-masing dengan kode biner sendiri.
- Nomor untuk satu karakter disebut titik kode.
Aadalah 65,aadalah 97,0digit adalah 48. - Titik kode bukan berarti karakter; ia adalah label yang disepakati. Teks dapat dibaca hanya karena kedua mesin menggunakan himpunan karakter yang sama.

Huruf adalah gambarnya; byte adalah angkanya

A character is stored as a number
Each character has a code number — 'A' is 65. Flip the bits to see that code in binary and hex, exactly how the computer holds it.
A character set such as ASCII defines:
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
A character set maps each character to a number (its code point), which is what the computer actually stores.
ASCII
- ASCII (American Standard Code for Information Interchange) menggunakan 7 bit, memberikan $2^7 = 128$ titik kode: huruf Latin dasar, digit, tanda baca, dan 32 kode kontrol seperti carriage return.
- Extended ASCII (ASCII diperluas) menggunakan 8 bit, memberikan 256 titik kode. 128 bawah identik dengan ASCII; 128 atas bervariasi menurut wilayah, inilah yang membuat email itu rusak.
- Anda tidak pernah diminta menghafal kode, tetapi Anda diminta memberikan jumlah: 7 bit, 128; 8 bit, 256.

How many different code points does 7-bit ASCII have?
Kesulitan 2/5 · 140 koin + bonus kecil pada penyelesaian pertama hari ini
7 bits give $2^7 = 128$ code points.
How many different code points does extended ASCII have?
Kesulitan 2/5 · 140 koin + bonus kecil pada penyelesaian pertama hari ini
Eight bits give $2^{8} = 256$. The lower $128$ match plain 7-bit ASCII; the upper $128$ vary by region.
Unicode
- Unicode adalah himpunan karakter universal: satu kode titik untuk hampir setiap karakter dalam setiap aksara yang hidup atau punah, serta simbol dan emoji, lebih dari 149,000 di antaranya.
- Titik kode terpisah dari cara penyimpanannya. Sebuah pengkodean (encoding) mengubah titik kode menjadi byte.
- UTF-8 UTF-8 menggunakan 1 untuk 4 byte per karakter dan kompatibel ASCII: 128 kode pertama adalah satu byte, identik dengan ASCII. UTF-16 menggunakan 2 atau 4 byte; UTF-32 menggunakan tetap 4.

Which is true of UTF-8?
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
UTF-8 is a variable-length Unicode encoding (1–4 bytes); its first 128 code points match ASCII, so plain ASCII text is valid UTF-8.
What is the relationship between Unicode and UTF-8?
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
The set assigns the numbers; the encoding decides how many bytes each number takes. UTF-16 and UTF-32 are other encodings of the same set.
Kartu ini telah diperbaiki, jadi ditampilkan dalam bahasa Inggris sampai terjemahannya diperbarui.
Worked example: compare ASCII and Unicode
- Give one advantage and one disadvantage of using Unicode instead of ASCII. [2]
- Advantage: Unicode represents far more characters 字符, so text in any script, Chinese, Arabic, Greek, and emoji can be stored, and a single document can mix languages; files are portable because there is no per-country code page to disagree about.
- Disadvantage: some Unicode encodings use more space for English-only text: UTF-16 and UTF-32 use more bytes per ASCII character than ASCII, while UTF-8 uses the same byte.
- Both halves are needed. "It has more characters" alone is one mark of two.
A key advantage of Unicode over ASCII is that it:
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
Unicode covers nearly every writing system plus symbols and emoji — far beyond ASCII's basic English set.
For English-only text, a file encoded in UTF-16 Unicode is larger than the same text in ASCII.
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
UTF-16 uses at least 2 bytes per character, so plain English text is larger than in ASCII — the trade-off for universal coverage. (UTF-8 stores ASCII characters in the same single bytes as ASCII.)
Which are advantages of Unicode over ASCII? Select semua that apply.
Kesulitan 2/5 · 140 koin + bonus kecil pada penyelesaian pertama hari ini
Some Unicode encodings use more space for plain English, but UTF-8 uses the same bytes as ASCII.
Contoh terpecahkan: ukuran file teks
- Pesan berisi 500 karakter disimpan dalam Extended ASCII. Berapa besar file tersebut dalam byte?
- Extended ASCII menggunakan 8 bit, satu byte, per karakter, jadi $500 \times 1 = 500$ byte, atau $500 \times 8 = 4000$ bit.
- Pesan yang sama dalam UTF-32? Empat byte per karakter, jadi 2000 byte.
- Tunjukkan bit-per-karakter, kalikan, lalu konversi sekali. Mencampur bit dan byte di tengah jalan adalah penyebab umum hilangnya poin.
A 500-character message is stored in extended ASCII. How many bytes does it need (ignore any header)?
Kesulitan 2/5 · 140 koin + bonus kecil pada penyelesaian pertama hari ini
Eight bits, one byte, per character: $500 \times 1 = 500$ bytes, or $4000$ bits. In UTF-32 the same text needs $2000$ bytes.
Membaca karakter dalam biner dan heksadesimal
- Karena titik kode hanyalah angka, ia dikonversi seperti angka lainnya.
Aadalah 65, yang merupakan0100 0001dalam biner dan41dalam heksadesimal. - Dua pola berguna: digit
0hingga9dimulai dari 48, dan huruf kecil bernilai 32 lebih tinggi dari huruf kapital, jadia(97) adalahA(65) ditambah 32. Perbedaan itu adalah satu bit. - Soal yang memberikan
A= 65 dan memintaEmenginginkan $65 + 4 = 69$, bukan tabel hafalan.

The ASCII code for A is 65. What is the ASCII code for E?
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
The letters are consecutive, so E is four after A. Nothing has to be memorised beyond one anchor value.
Kartu ini telah diperbaiki, jadi ditampilkan dalam bahasa Inggris sampai terjemahannya diperbarui.
Marks that slip away
- ASCII is 7 bits and 128 code points; extended ASCII is 8 bits and 256. Do not write 8 bits for plain ASCII.
- Unicode is a character set 字符集; UTF-8 is an encoding of it. They are not two rival sets.
- UTF-8 is variable length, 1 to 4 bytes, not always one byte and not always four.
- Some Unicode encodings use more file space for plain English than ASCII; UTF-8 uses the same bytes for ASCII characters.
Kartu ini telah diperbaiki, jadi ditampilkan dalam bahasa Inggris sampai terjemahannya diperbarui.
You've got it
- a character set gives each character a code point; text is numbers plus an agreement about how to read them
- ASCII: 7 bits, 128 code points, English only · extended ASCII 扩展ASCII码: 8 bits, 256, the top half varies by region
- Unicode: one code point for every script and emoji, stored by an encoding; UTF-8 is 1 to 4 bytes and ASCII-compatible
- Unicode gains characters, portability and mixed languages; some encodings use more file space for plain English text, while UTF-8 uses the same bytes as ASCII
Apa yang salah? Hanya tim situs yang dapat melihatnya.