Encoding Schemes Interview Questions and Answers: ASCII, Unicode and Worked UTF Traces

Prepare clear, interview-ready answers on ASCII, Unicode and UTF formats. Trace `क` in UTF-8, derive the rocket surrogate pair, and diagnose broken text.

KnowledgeGate Team

Exam prep & CS education

Updated 5 Dec 20265 min read
Encoding Schemes Interview Questions and Answers: ASCII, Unicode and Worked UTF Traces

Character, byte, code point and glyph are different things. A clear interview answer defines each term, traces a non-English character through UTF-8 and UTF-16, and diagnoses malformed or misdecoded bytes. Employers may probe these ideas in different orders; the technical distinctions and calculations remain the same. Use IT placement preparation for the wider interview process.

1. What an Encoding Scheme Actually Maps

What is a character encoding? A character is an abstract text element. Unicode assigns it a code point such as U+005A. UTF-8 represents that code point with code units and, when serialised, bytes. A font chooses the displayed glyph.

For Z, the character is Z, code point U+005A, ASCII value 0x5A, and UTF-8 byte 5A. The glyph can vary by font.

Are BCD, Gray code, Base64 and UTF-8 the same kind of encoding? No. BCD and Gray code represent numeric information; Base64 maps bytes into a restricted text alphabet; character encodings map text values to code-unit or byte sequences. The BCD and Special Codes solved questions cover numeric codes. These are not encryption or compression.

2. ASCII Questions That Test Whether the Basics Are Precise

Is ASCII 7-bit or 8-bit? Standard ASCII defines 128 values, from decimal 0 to 127, so 7 bits are sufficient. An 8-bit byte can store an ASCII value with a leading zero, but that does not turn standard ASCII into one universal 8-bit code. The phrase “extended ASCII” is ambiguous unless the code page is named.

Check the arithmetic:

  • Uppercase Z = 0x5A = 90.

  • Lowercase z = 0x7A = 122.

  • Their difference is 0x7A - 0x5A = 0x20 = 32.

  • Digit character '7' = 0x37 = 55, while '0' = 0x30 = 48, so 0x37 - 0x30 = 7.

Numeric value 7, character '7', and byte 0x37 are not interchangeable labels. A bit pattern acquires meaning only through its agreed interpretation.

3. Unicode Versus UTF-8, UTF-16 and UTF-32

Is Unicode an encoding, and is every Unicode character 16 bits? Unicode assigns code points; UTF-8, UTF-16 and UTF-32 encode them. “Unicode is 16-bit” is wrong because UTF-16 uses two 16-bit code units above U+FFFF, while UTF-8 uses one to four bytes.

Character

Code point

UTF-8 bytes

UTF-16 code units

Z

U+005A

5A

005A

क

U+0915

E0 A4 95

0915

🚀

U+1F680

F0 9F 9A 80

D83D DE80

The encoding columns describe representation; they do not determine glyph width on screen.

How much space does Zक🚀 take? UTF-8 uses 1 + 3 + 4 = 8 bytes. UTF-16 uses 1 + 1 + 2 = 4 code units = 8 bytes, excluding a byte-order marker. UTF-32 uses 3 x 4 = 12 bytes. Three code points do not imply three bytes or three UTF-16 code units.

4. Fully Worked UTF-8 Interview Trace: Encode क as E0 A4 95

The input is Devanagari क: U+0915, hexadecimal 0x0915, decimal 2325, and 16-bit binary 0000 1001 0001 0101. It falls in UTF-8's three-byte range, so use 1110xxxx 10xxxxxx 10xxxxxx.

Split the payload as 0000 | 100100 | 010101. Filling the template gives 11100000 | 10100100 | 10010101, or E0 | A4 | 95.

Decode by stripping the prefixes to recover 0000, 100100 and 010101. Their concatenation is 0000100100010101 = 0x0915, hence U+0915. For Kक, the bytes are 4B E0 A4 95: 4 bytes, 2 code points and, for this string, 2 visible grapheme clusters. An API named length may count any of these measures, so check its contract.

Diagram showing Devanagari क mapped from U+0915 through the UTF-8 bit template to E0 A4 95, then decoded back; Kक occupies four bytes.

5. Fully Worked UTF-16 Follow-Up: Why 🚀 Needs a Surrogate Pair

How does UTF-16 encode U+1F680? First subtract 0x10000:

0x1F680 - 0x10000 = 0xF680

The upper ten-bit value is 0xF680 >> 10 = 0x3D. The lower ten-bit value is 0xF680 AND 0x3FF = 0x280. Add them to the surrogate bases:

  • High surrogate: 0xD800 + 0x3D = 0xD83D

  • Low surrogate: 0xDC00 + 0x280 = 0xDE80

The sequence D83D DE80 is two code units for one code point, not two characters. UTF-16BE serialises it as D8 3D DE 80; UTF-16LE uses 3D D8 80 DE. Endianness applies to the serialised code units, not U+1F680 itself. Cutting between D83D and DE80 creates an unpaired surrogate, not half a rocket.

Flow diagram deriving the UTF-16 surrogate pair D83D DE80 for U+1F680 and showing big-endian and little-endian byte orders.

6. Debugging Questions: Mojibake, Invalid UTF-8 and Normalisation

Why does é sometimes become é? The character é = U+00E9 is UTF-8 C3 A9. If a Windows-1252 decoder interprets those bytes, they become U+00C3 (Ã) and U+00A9 (©), displayed as é. Re-encoding the damaged text as UTF-8 gives C3 83 C2 A9. Recover the original bytes and decode once with the declared encoding; do not replace visible fragments.

Is E2 28 A1 valid UTF-8? No. E2 announces three bytes, but 28 = 00101000 does not match continuation form 10xxxxxx, so the sequence is malformed at 28. Use a standards-compliant decoder with an explicit reject-or-replace policy.

Composed é is U+00E9, bytes C3 A9; decomposed e plus combining acute is U+0065 U+0301, bytes 65 CC 81. They can render alike while code-point and byte comparisons differ. Document a normalisation form at comparison and search boundaries rather than assuming visual equality means byte equality.

7. How Interview Depth Increases, Plus the Traps to Avoid

Interview depth commonly progresses from definitions to traces: define ASCII, Unicode and UTF, then encode U+0915, explain D83D DE80, diagnose C3 A9, reject E2 28 A1, and state what a language's length counts.

Trap

Precise correction

“Unicode is always 16-bit.”

Unicode code points are represented differently by each UTF.

“One character is one byte.”

क takes 3 bytes in UTF-8.

“ASCII and UTF-8 are unrelated.”

Bytes 00-7F represent ASCII characters identically in UTF-8.

“Base64 fixes text encoding.”

Base64 transforms bytes; it does not identify their original text encoding.

“Endianness changes the code point.”

It changes the byte serialisation of multi-byte code units.

“Visible equality proves string equality.”

C3 A9 and 65 CC 81 show why normalisation matters.

Use Encoding Schemes MCQs and solved ASCII and UTF questions for concept practice, not employer-endorsed ordering or a frequency forecast.

8. The 60-Second Model Answer and the Next Step

An encoding maps text to code units and bytes. ASCII is a 7-bit code whose 00-7F values stay unchanged in UTF-8. Unicode assigns code points; UTF-8, UTF-16 and UTF-32 encode them. A symbol may use multiple bytes or code units, so byte, code-point and grapheme counts differ. Reliable programs declare encoding at I/O boundaries, handle malformed input explicitly and normalise where comparison rules require it.

Cannot reproduce E0 A4 95 or D83D DE80? Study Computer Architecture and Organisation. For broader revision, use Computer Science Fundamentals for Placements by Sanchit Sir. Return to the question set for targeted revision; reproduce both traces without notes.