Handling ASCII Character in Python

Uniqtech
Interview Buddy
Published in
6 min readJan 2, 2018

--

Please clap for the story to support us. More technical interview, data structure and algorithms articles coming soon. We write tutorials for beginners, those prepping for interviews, those need a quick review.

In technical interviews (focus of this article), it’s okay to assume the old ASCII chart with only 128 total characters which map to the number 0–127. Unicode started with 200 or so characters has now expanded to more than one million — 1,114,112!

For text processing, text formatting using Python, not in an interview setting, refer to this documentation link. common string operations in python https://docs.python.org/3/library/string.html

ASCII, pronounced like askee, is considered a simple encoding for texts, hence it can be reasonable to discuss and test in an interview. Each character is 8-bit. For example A is 1100001 in binary numbers, and correspond to the decimal value of 97. We will talk about how check that later. Notice that capitalized A’s decimal value is 65, the difference is 32 and it is case sensitive. More modern encoding including UTF-8, UTF-16, UTF-32, where the digit stands for bits. For example UTF-32 is encoded in 32 bits.

While ASCII works well for simple English, UTF Is better fit for modern, global needs : accommodating special characters such as emojis and many different languages such as Chinese, Hebrew.

Unicode is a superset of ASCII, and the numbers 0–128 have the same meaning in ASCII as they have in Unicode. For…

--

--