HackerTube.dev

Pragmatic Unicode, or, How do I stop the pain?

Next Day Video · 80.4K views · 2012-03-16 · 36:21

Open on YouTube ↗

If playback is restricted in your region, try opening the original video. Use Mark watched to add it to your marked videos.

Overview

Ned Batchelder's PyCon 2012 talk gives a quick overview of what Unicode is, then focuses on what a Python programmer needs to handle text correctly. It presents the 'Unicode sandwich' strategy: decode bytes at input, work with Unicode internally, encode at output.

On Hacker News

Commenters point to it as the clearest explanation of Python's bytes versus Unicode model and the Unicode sandwich, which finally makes the confusion click.

Recommended by 2 HN people across 2 months · HN mentions 2015–2019

Topics

Search by tags

What people said

jteppinette · 2019-05 · Strong recommendation

You have to invest some time in understanding how strings (byte strings and unicode) work in Python. I put this off for way too long. After A TON OF PAIN I decided to put the time in to watch the talk "Pragmatic Unicode, or, How do I stop the pain?"[0] by Ned Batchelder and it all just clicked. Now, I make unicode sandwiches like a boss. [0] [VIDEO]

Read the original HN comment ↗
ptx · 2015-01 · Recommendation

From a quick skimming through the docs[0], Perl 5.8's Unicode support sounds a lot like Python 2's except that the default encoding is latin1 instead of ASCII - i.e. unlike the Python 3 way of explicitly decoding binary data into Unicode text at the point where it's read (where presumably the encoding of the data is known), it will defer the decoding until the data is used (at some completely unrelated point in the program) and decode it with some assumed globally agreed upon encoding. Since there is no globally agreed encoding (Windows even has different legacy encodings between Win32 and the command prompt!) this will appear to work as long as the data is ASCII but later, when you least expect it (and someone inputs a non-ASCII string), give UnicodeDecodeError in Python 2 or garbage data in Perl 5.8. Ned Batchelder gave an excellent talk[1] that explains how the Python 3 approach to Unicode works. I think it makes a lot more sense once you understand it; the Python 2 way was clearly broken, and it looks like Perl 5 has the same problem but hides it better. [0] [LINK] [1] [VIDEO]

Read the original HN comment ↗
thanksgiving · 2017-11 · Reference

I don't know the details (because I don't understand unicode) but I am not sure what you said is possible. But to me ASCII seems like a hindrance. ``` fmt.Println("Hello, 世界") ``` This line of go lang looks beautiful. I bet they never have to worry about bytes vs Unicode. Here is python... [VIDEO] I'll add one more assertion to the list. People are born and people die. It is not fair for us to impose our mistakes and sins to the next generation. With that being said, my thought was simply all the scripts that are in python (even the simple build for Firefox was python 2 only last time I checked). The way forward for anyone new to python is for us to tell them: Python 2 doesn't matter. Don't look at it. Learn python by which I mean 3.0+ I still don't get why Google of all places can't support python 3 in its standard app engine. To me it sounds like standard is deprecated for the flexible (which doesn't have a free tier).

Read the original HN comment ↗

Sources

Video by Next Day Video, played through YouTube.

Data and selection notes

HN summaries and labels may contain AI errors. HN dates refer to discussions, not video publication.

HN Library: HackerTube export (2026-10-31) and open-index/hacker-news. Upstream summaries and classifications may contain AI errors.

Views, duration and playback status refresh separately from the published catalog. When an update fails, existing data remains visible.

Selection checks
  • SaaS & AI candidates: Topic keywords do not match
  • Editor-approved picks: Editorial review is required

Rule matches identify candidates. They do not guarantee video quality or financial results.

About the library and its sources