THE INVESTIGATION
The length that counts letters
An upload advertises fewer bytes than its UTF-8 payload contains.
Requests & BoundariesUnicodeByte lengths
What’s going wrong
An API accepts ASCII uploads but truncates some international text. The body is a Python string; the transport sends UTF-8 bytes.
Stdin is a JSON array of Unicode strings without unpaired surrogates. For each body, print its Content-Length as the number of bytes in its UTF-8 encoding. Preserve array order. Empty strings have length zero; an empty input array prints []. Whitespace, line endings and embedded nulls are ordinary payload. Print one compact JSON array of integers. No actual network request is made.
Expected behavior
Distinguish logical text length from transport byte length.
Reproduction
01 A visible character occupies several bytes
["€"]
[3]
02 ASCII control
["hello"]
[5]
03 Empty payload
[""]
[0]
Before you begin
- Start here: identify the unit promised by an output.
- Python strings, lists and dictionaries
- Read the report contract before changing code
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
Ready when you are
Every fix starts with a failing test.
Read the report, then sign in to start your investigation.