Start United States USA — software Projecting Unicode to ASCII

Projecting Unicode to ASCII

415
0
TEILEN

We may always need to do the unexpected, including going from Unicode to ASCII. We take a look at how to accomplish this in Python.
Let’s be friends:
Comment (0)
Join the DZone community and get the full member experience.
Sometimes you need to downgrade Unicode text to more restricted ASCII text. For example, while working on my previous post, I was surprised that there didn’t appear to be an asteroid named after Poincaré. There is one, but it was listed as Poincare in my list of asteroid names.
I used the Python module unidecode to convert names to ASCII before searching, and that fixed the problem. Here’s a small example showing how the code works.
This produces:
Installing the unidecode module also installs a command line utility by the same name. So you could, for example, pipe text to that utility.
I titled this post “Projecting Unicode to ASCII” because this code is a projection in the mathematical sense.

Continue reading...