Archive for October 5, 2023

Thursday, October 5, 2023

The Absolute Minimum Every Software Developer Must Know About Unicode in 2023

Nikita Prokopov (Hacker News):

The problem is, you don’t want to operate on code points. A code point is not a unit of writing; one code point is not always a single character. What you should be iterating on is called “extended grapheme clusters”, or graphemes for short.

[…]

Even in the widest encoding, UTF-32, 👨‍🏭 will still take three 4-byte units to encode. And it still needs to be treated as a single character.

[…]

But whatever you choose, make sure it’s on the recent enough version of Unicode (15.1 at the moment of writing), because the definition of graphemes changes from version to version.

[…]

Unicode motivation is to save code points space (my guess). Information on how to render is supposed to be transferred outside of the string, as locale/language metadata.

jcranmer:

The truth of the matter is that there are several different definitions of “character”, depending on what you want to use it for. An extended grapheme cluster is largely defined on “this visually displays as a single unit”, which isn’t necessarily correct for things like “display size in a monospace font” or “thing that gets deleted when you hit backspace.” Like so many other things in Unicode, the correct answer is use-case dependent.

Previously:

Avoid Overspending for iPhone 15 USB-C Cables and Chargers

Glenn Fleishman:

Avoid Apple’s $29 USB-C to Lightning adapter. It’s more expensive than most 2-foot-long cables with USB-C plugs on both ends rated for Thunderbolt 4/USB4 speeds of 40 Gbps and 100W.

Instead, I recommend upgrading cables instead of adding adapters. Why keep using a USB Type-A to Lightning cable for charging when you could get a USB Type-A to USB-C replacement for under $10? Or, if adapters still appeal, I encourage you to pick up a well-reviewed six-pack of Lightning, Type-A, and USB-C nubbin adapters for under $10. Carefully read reviews for third-party USB cables and adapters for comments about quality and overheating because not all meet the kind of standards Apple requires of Lightning-based products using the MFi branding and certification program.

John Siracusa is skeptical about the safety of all those little adapters. I’ve found them useful, especially when traveling, because they reduce the number of actual cables that I need to squeeze into my bag. With iPhone switching to USB-C, I should be able to get away with a single Lightning cable for my keyboard, mouse, and AirPods.

Previously: