Free degree-level computing lessons for careful independent study.

Degree Level Programmes · Search, data management and analytics · Lesson 3

Character Sets, Unicode and Text Representation

Show how text is represented for storage and retrieval, with emphasis on Unicode, UTF-8, code points, encodings and normalisation issues in multilingual collections.

Lesson overview

Show how text is represented for storage and retrieval, with emphasis on Unicode, UTF-8, code points, encodings and normalisation issues in multilingual collections.

CourseInformation Storage and Retrieval
Topic strandData representation
Assessment styleWorked scenario, applied task and digital exam practice
EvidenceDefinitions, representation, method, result and interpretation

Starter

Write down the user need, the data being stored or searched, and the decision the system has to support. Then predict which representation, index, query method or governance control will matter most in this lesson.

Learning objectives

  • Explain the difference between a character, code point and encoded byte sequence.
  • Describe why Unicode and UTF-8 matter for web-scale retrieval.
  • Identify text normalisation problems that affect matching and search.

Learning outcomes

  • Students can explain the difference between a character, code point and encoded byte sequence.
  • Students can describe why Unicode and UTF-8 matter for web-scale retrieval.
  • Students can identify text normalisation problems that affect matching and search.

Key vocabulary, acronyms and terminology

Unicode
A universal character repertoire assigning code points to written symbols.
UTF-8
Unicode Transformation Format - 8-bit: a variable-length Unicode encoding widely used on the web.
code point
A numeric identifier for a Unicode character.
encoding
The rule for representing characters as bytes.
normalisation
A process for putting equivalent text forms into a standard representation.
NFC
Normalisation Form C: a Unicode normalisation form that prefers composed characters where possible.
NFD
Normalisation Form D: a Unicode normalisation form that decomposes characters into base characters plus combining marks.
collation
Rules for sorting and comparing text in a language-aware way.

Detailed teaching notes

Core concept

Search systems do not store abstract letters directly; they store bytes interpreted through an encoding. Unicode gives a shared code space for scripts, symbols and emoji, while UTF-8 makes that code space practical for web text.

Representation choice

The same visible word can have more than one byte representation, especially with accents or combined characters. A retrieval system that ignores Unicode normalisation may fail to match strings that look identical to users.

Method and reasoning

When diagnosing text retrieval problems, follow the chain: character, code point, encoding and normalisation. Decide whether comparison should be exact bytes, case-folded terms, accent-insensitive terms or language-aware collation.

Risk and limitation

A system can appear to work in English test data yet fail with names, accented words and non-Latin scripts. Text representation must be designed before tokenisation and indexing, not patched afterwards.

Degree-level deep dive

Characters are not bytes

Students should separate the visible character, the Unicode code point and the byte encoding. UTF-8 is an encoding of Unicode code points; it is not the same thing as the Unicode character repertoire itself.

Normalisation changes matching

NFC and NFD can represent visually similar text differently. A retrieval system must decide whether to normalise, case-fold, accent-fold or preserve exact forms, because each choice changes search results and display behaviour.

What excellent work shows

A strong answer stores original text for display, normalises a search field for matching, and explains the limits of broad matching. Legal names, citations and multilingual search need careful policies rather than a simple lower-case everything rule.

Concrete example to study

Cafe with an accent

Visible text: cafe with acute e
Form 1: U+0063 U+0061 U+0066 U+00E9
Form 2: U+0063 U+0061 U+0066 U+0065 U+0301

Reasoning

  1. Both forms may display similarly to a reader.
  2. A byte-level comparison may treat them as different strings.
  3. Normalise to NFC for indexing, store the original for display, and decide whether accent folding should also match 'cafe' without the accent.
Reveal takeaway

The example shows why 'we use UTF-8' is not enough: retrieval also needs a comparison and normalisation policy.

Worked example

Scenario

A search box fails to match 'cafe' with an acute accent when records come from two different publishers.

Worked solution

  1. Inspect whether the visible accented letter is stored as one composed code point or as a base letter plus combining mark.
  2. Apply Unicode normalisation, such as NFC, before indexing and querying.
  3. Decide whether the search should also use accent folding so cafe and cafe with acute can match.
  4. Record the policy because exact legal names may require stricter matching than broad discovery search.
Reveal model result

The fix is not merely 'use UTF-8'. UTF-8 stores both forms correctly, but retrieval needs a normalisation and comparison policy so equivalent text is indexed consistently.

Define the data, choose the representation, apply the method, interpret the result.\text{Define the data, choose the representation, apply the method, interpret the result.}

Applied retrieval task

Audit a multilingual search feature for representation problems.

Deliverables

  1. List three strings that may expose encoding or normalisation bugs.
  2. State whether exact, case-insensitive or accent-insensitive matching is appropriate.
  3. Write a short indexing policy for Unicode normalisation.

Success checks

  • The audit separates encoding from matching policy.
  • The examples include at least one non-ASCII case.

Common misconception

Saying 'we use Unicode' does not automatically solve matching. Encoding, normalisation, tokenisation and collation each affect retrieval in different ways.

Quick checks

1. In this lesson, why does Unicode matter?

2. Which answer best shows degree-level understanding of character sets, unicode and text representation?

Digital exam practice

Example exam task

A university repository stores author names from English, Welsh and French publications. Users complain that names with accents are sometimes missing from search results. In your answer, define the relevant objects or data structures, use course-specific vocabulary, show the method rather than only the result, and finish with a decision about the storage or retrieval system.

Notation and technical toolkit

U+00E9Unicode code point for e with acute Use code-point notation when explaining characters precisely.
UTF-8variable-length byte encoding Use for web-compatible storage and transmission.
NFC / NFDUnicode normalisation forms Use when explaining canonical text equivalence.

What a good answer is expected to show

A strong answer for Character Sets, Unicode and Text Representation the answer should explain code points, UTF-8 and Unicode normalisation, then propose a retrieval policy that preserves original spelling while improving matching. It should connect the formal or technical representation to the user's information need instead of listing terms without using them.

How to solve it

  1. Explain how characters become encoded byte sequences.
  2. Identify why visually identical strings can compare differently.
  3. Apply a normalisation step before indexing and query processing.
  4. State when accent folding is helpful and when exact preservation is required.

Model answer

Reveal model answer

Unicode provides code points for the characters in the names, and UTF-8 encodes those code points as bytes for storage and web transmission. The search failure may occur because the same visible accented character is stored in composed and decomposed forms. I would store the original name for display, normalise text to a chosen form such as NFC for indexing, and optionally create an accent-folded search field for broad discovery. Exact author display and citation must preserve the original spelling.

Practise next

  1. Explain why UTF-8 and Unicode are related but not identical.
  2. Design two tests for a search box that handles accented names.

Self-marking criteria

  • Defines the scenario objects, data forms or system components before solving.
  • Uses the lesson vocabulary accurately and in context.
  • Shows a clear method with enough working for a marker to follow.
  • Connects the result back to retrieval, storage, analytics or governance.
  • States a limitation, trade-off or quality risk rather than presenting the answer as absolute.

Extension

Research how case folding differs from lowercasing in languages outside English, then explain the retrieval risk.

Study route

Save a short worked answer from this lesson using this pattern: define the need or data, choose the representation, show the method, state the result and interpret the implication for the system.

Next lesson: XML, Markup, Validation and Document Trees.