Sitemap
TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

Processing Text with Unicode in Python

The Best Practice for Data Scientist

4 min readMay 10, 2020

--

Press enter or click to view image in full size
Photo by Kayla Kozlowski on Unsplash

We are able to read these lines of text because we are familiar with the Latin alphabet with 26 characters that are used in English. Other languages have own their own characters and they are all need to be encoded so they can be represented by our computer. For many decades, computer were able to represent characters based on the ASCII¹ code table.

The ASCII table

Press enter or click to view image in full size

ASCII is a standard that assigns letters, numbers, and other characters in the 256 slots available in the 8-bit code. With languages that do not use the Latin alphabet such as Chinese, Greek, Japan, ASCII wouldn’t able to represent these text and we need a new character set. They’re Unicode².

The Unicode table

Press enter or click to view image in full size

Text in Python could be presented using unicode string or bytes.

Encode unicode string

--

--

Anh T. Dang
Anh T. Dang

Written by Anh T. Dang

I write about things that I like and things that I don’t, mainly in the business, art and tech sphere. Sign up for my newsletter http://junryo.xyz

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.