Live data from Hacker News

What every software developer must know about Unicode in 2023

tonsky.me

471–480 of 572 posts

Re: What every software developer must know about Unicode in 2023

#471
post #469

Earlier quoted context omitted.

> they were in some old Japanese character set This implies that they're obsolete, but they're not -- they're still in very common use today. You can type them in Japanese by typing まる (maru, circle) and the number, then pick it out of the IME menu. Some IMEs will bring them up if you just type the number and go to the menu, too. :)

What do the Japanese use the circled numbers for?

Ordinals and references, like this:

① Draw some circles

② Draw the rest of the owl

Commentary: ① is simple but ② is masking many complex steps that are necessary to draw an owl.

Re: What every software developer must know about Unicode in 2023

#473
post #290

Earlier quoted context omitted.

In terminals there is a distinction between single-width and double-width characters (east-asian characters, in particular). E.g. the three characters A美C would take up the width of four ASCII monospace characters, the “美” being double-width. Similarly, for composed characters like say the ligature “ff”, you may want to backspace as if it was two “f”s (which logically it is, and decomposes to in NFKD normalization).

Unicode even has distinct full width and half width variants of Japanese katakana - where ‘full width’ is (in theory) as wide as two Latin characters. Latin: Katakana Full width: カタカナ Half width: カタカナ (How that fixed width text looks in a web browser is anyone’s guess though. On iOS none of the Japanese kana stay on the fixed grid.)

The background here is that both are contained in the Japanese Shift JIS character set, and Unicode provides roundtrip compatibility. And they are in Shift JIS because the half-width katakana were in the 8-bit JIS character set [0] used with text-mode displays where all characters have the same width. To preserve screen layout, these later had to be distinguished from full-width katakana.

[0] https://en.wikipedia.org/wiki/JIS_X_0201

Re: What every software developer must know about Unicode in 2023

#474

Earlier quoted context omitted.

Works like a normal website with JavaScript disabled. I didn't even know it did fancy junk until reading the comments here. NoScript saves the day again! I don't know how people can browse the web without it.

I never understood how people can browser the we WITH IT. Even 10 years ago. today more then ever basically every website needs JS to work properly. I basically never come across a page where I have the urge to disable JS. I have a large list of adblock lists active that also help getting rid of cookie banners and other shit. I can not imagine manually approving JS for every site. And again doing the inverse and have…

By default the script for the page itself is whitelisted, it is just the third party scripts that are blocked. This works fairly often, but there are a few sites that you can also globally unblock because they provide value. One example is mathjax, used to format equations on many pages.

Re: What every software developer must know about Unicode in 2023

#475

There's one part of this document that I would push extremely hard against, and that's the notion that "extended grapheme clusters" are the one true, right way to think of characters in Unicode, and therefore any language that views the length in any other way is doing it wrong. The truth of the matter is that there are several different definitions of "character", depending on what you want to use it for. An extende…

> And for this reason, String iteration should be based on codepoints Why not offer both and be clear about it? Rather than just "length", why not call them code points? The Python docs for "len" which can be called on a unicode string say "Return the length (the number of items) of an object.". It doesn't look like a clear and easy to use API to me.

If you insist that `len` shouldn't be defined on strings, and the default iterator should be undefined in python then:

  for c in "Hello":
    pass
should throw an exception. Also

  if word[0] == 'H':
     pass
should throw an exception.

This would have been an extremely controversial suggestion when python3 came out to say the least.

Codepoints is a natural way of defining unicode strings in python, and it mostly works the way you expect once you give it a bit of thought. It is lower level than, say, grapheme clusters, but its more well defined and it provides the proper primitives for dealing with all use cases.

Re: What every software developer must know about Unicode in 2023

#476
post #290

Earlier quoted context omitted.

In terminals there is a distinction between single-width and double-width characters (east-asian characters, in particular). E.g. the three characters A美C would take up the width of four ASCII monospace characters, the “美” being double-width. Similarly, for composed characters like say the ligature “ff”, you may want to backspace as if it was two “f”s (which logically it is, and decomposes to in NFKD normalization).

Unicode even has distinct full width and half width variants of Japanese katakana - where ‘full width’ is (in theory) as wide as two Latin characters. Latin: Katakana Full width: カタカナ Half width: カタカナ (How that fixed width text looks in a web browser is anyone’s guess though. On iOS none of the Japanese kana stay on the fixed grid.)

[deleted]

Re: What every software developer must know about Unicode in 2023

#477
post #141

>3 Grapheme Cluster Boundaries >It is important to recognize that what the user thinks of as a “character”—a basic unit of a writing system for a language—may not be just a single Unicode code point. Instead, that basic unit may be made up of multiple Unicode code points. To avoid ambiguity with the computer use of the term character, this is called a user-perceived character. For example, “G” + grave-accent is a use…

> These user-perceived characters are approximated by what is called a grapheme cluster, which can be determined programmatically. From everything i've read or heard about unicode, "determined programmatically" is false?

I quoted Unicode specification, so no, it's not false.

Re: What every software developer must know about Unicode in 2023

#478

Earlier quoted context omitted.

> The content of a webpage is required to be expressed in every supported language, but the HTTP protocol must not. And it would make no sense at all to add internationalization to intra-machines protocol, where ASCII is enough and has been enough for decades. I guess no URLs with funny characters then. "GET /profile/renée" => 500 error, woohoo. > And if someone complains that ASCII only supports English, well... suc…

> I guess no URLs with funny characters then. "GET /profile/renée" => 500 error, woohoo. That's not really a slam dunk. Lots of sites don't let you have your name in the URL at all, and the average person's experience is that their name would be taken by someone else before they signed up.

Try looking at the moon rather than the finger next time.

Re: What every software developer must know about Unicode in 2023

#479

Prior to this article, I knew graphemes were a thing and that proper unicode software is supposed to count those instead of bytes or code points. I didn't know that unicode changes the definition of grapheme in backwards incompatible fashion annually, so software which works by grapheme count is probably inconsistent with other software using a different version of the standard anyway. I'm therefore going to continue…

Comparing by memcmp will result in false negatives unless you can ensure that all incoming text gets normalized to a particular canonical form.

Even then there are minefields in comparing text, especially case insensitive matching and supporting CKJ.

Re: What every software developer must know about Unicode in 2023

#480
post #257

Earlier quoted context omitted.

I expect to delete the character "á". And I prefer consistency too so I expect "œ" and " " and " " to be deleted as one unit. edit: emojis are filtered by HN

Even the emoji's that you create by combining multiple emojis? Type one emoji, then a second, it merges into one. What happens when you backspace?

I'd say delete the whole with backspace, but only the last if you undo.
Post reply on HN