Strings, Characters, and Encodings
How text is stored as bytes and Unicode.
Strings, Characters, and Encodings is a free NLP Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the NLP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Text Is Made of Characters
Every piece of text you process is a string: an ordered run of characters like letters, digits, spaces, and symbols. 🔤
Strings in Python
In Python a string is wrapped in quotes. You can store a whole sentence in a single variable and work with it as one value.
text = "NLP turns text into insight"
print(type(text)) # <class 'str'>Each Character Has a Position
A string is indexed, so each character sits at a numbered position starting from zero. That lets you reach any single letter.
word = "data"
print(word[0]) # d
print(word[3]) # aComputers Store Numbers
A computer cannot store the letter A directly. It stores a number, and an encoding is the agreed map between characters and those numbers.
ASCII Came First
ASCII mapped 128 basic English characters to numbers. It worked for plain English but had no room for accents or other alphabets.
Unicode Covers Everything
Unicode gives every character a unique code point, from English letters to Chinese script and emoji. Modern Python strings are Unicode.
Code Points in Python
The ord function shows a character's Unicode number, and chr turns a number back into its character.
print(ord('A')) # 65
print(chr(233)) # éEncoding Turns Text Into Bytes
To save or send text, Python turns it into bytes using a scheme like UTF-8. Bytes are what files and networks actually carry.
data = "café".encode("utf-8")
print(data) # b'caf\xc3\xa9'UTF-8 Is the Default Choice
UTF-8 stores common characters in one byte and rarer ones in more. It is compact, universal, and the standard for almost all text today.
Decoding Bytes Back to Text
Reading raw bytes means decoding them with the same scheme used to encode. The wrong scheme produces garbled or broken characters.
raw = b'caf\xc3\xa9'
print(raw.decode("utf-8")) # caféEncoding Mistakes Cause Mojibake
Decoding with the wrong encoding gives mojibake, that jumble of odd symbols. Always know and match your encoding to avoid it.
Quick Check
Let us check the difference between two key text standards.
Recap: Text as Encoded Strings
You saw that text is a string of characters, mapped to numbers by Unicode and stored as UTF-8 bytes. Match encodings and your text stays clean. ✅
Frequently asked questions
Is the “Strings, Characters, and Encodings” lesson free?
Yes — the full text of “Strings, Characters, and Encodings” is free to read here on the web, and the NLP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the NLP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Strings, Characters, and Encodings”?
How text is stored as bytes and Unicode. You practise NLP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start NLP Academy?
No prior experience is required. NLP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Strings, Characters, and Encodings” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this NLP Academy lesson?
Yes. Every NLP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Strings, Characters, and Encodings
- Reading Text Files Into Python
- Counting Words and Characters
- Building Your First Word Frequency Table