What are character encoding issues such as mojibake, and how do you handle text encoding problems during cleaning?

Quick Overview

Asks what causes mojibake and other character encoding problems in text data, and how to deal with them during data cleaning. Tests explicit decoding, encoding detection, repairing corrupted strings, Unicode normalization and a sound policy for undecodable bytes.

What are character encoding issues such as mojibake, and how do you handle text encoding problems during cleaning?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Other

What are character encoding issues such as mojibake, and how do you handle text encoding problems during cleaning? Assume the text columns come from several sources, such as CSV exports, scraped pages and an older database. ```hint Bytes versus text Separate the step where bytes become text from the steps that work on text, and ask where each kind of problem gets in. ``` ```hint Telltale patterns Think about which character sequences appear when UTF-8 is read with a single-byte encoding, and how you could count them across a whole column. ``` ### What a Strong Answer Covers - What mojibake is and the decoding mismatch that produces it, including double encoding. - How to decode input explicitly, detect an unknown encoding and confirm the guess. - How to repair text that is already corrupted, and how to find corrupted rows at scale. - Unicode normalization and the choice between NFC and NFKC. - How to treat bytes that cannot be decoded, and which encoding to store and emit downstream. ### Follow-up Questions - A CSV loads without errors, but every apostrophe in one column shows as "’". What happened, and how do you fix the column? - Two customer names look identical but do not match in a join. What would you check? - How would you monitor a daily ingestion job for new encoding problems? - When is NFKC normalization the wrong choice?

Overview: Asks what causes mojibake and other character encoding problems in text data, and how to deal with them during data cleaning. Tests explicit decoding, encoding detection, repairing corrupted strings, Unicode normalization and a sound policy for undecodable bytes.

Nov 24, 2026
mediumData ScientistOtherData Manipulation (SQL/Python)
0
0

What are character encoding issues such as mojibake, and how do you handle text encoding problems during cleaning? Assume the text columns come from several sources, such as CSV exports, scraped pages and an older database.

What a Strong Answer Covers Guidance

  • What mojibake is and the decoding mismatch that produces it, including double encoding.
  • How to decode input explicitly, detect an unknown encoding and confirm the guess.
  • How to repair text that is already corrupted, and how to find corrupted rows at scale.
  • Unicode normalization and the choice between NFC and NFKC.
  • How to treat bytes that cannot be decoded, and which encoding to store and emit downstream.

Follow-up Questions Guidance

  • A CSV loads without errors, but every apostrophe in one column shows as "’". What happened, and how do you fix the column?
  • Two customer names look identical but do not match in a join. What would you check?
  • How would you monitor a daily ingestion job for new encoding problems?
  • When is NFKC normalization the wrong choice?