Live data from Hacker News

What every software developer must know about Unicode in 2023

tonsky.me

551–560 of 572 posts

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

#552
post #126

Earlier quoted context omitted.

> as in they should things you can just use by-default without thinking about it That time has passed. If you want to know the length of a string, you really should indicate what length type you mean.

There was no string.length in Swift for a while. Then they added one that just does what the user expects, get the number of grapheme clusters. If a user figures out that this isn't what they want, they can go use the other length method.

except if it's server swift code, then it doesn't do what the user expects at all

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

#553
post #506

Earlier quoted context omitted.

No. Just whitelist the main domain for sites that are obviously broken. Then try one or two likely subdomains if that's not enough. In the rare cases where it still wants more crap enabled, then it's usually not worth the effort, close tab and move on to something else. As you build up a whitelist over time, it becomes pretty rare that you need to interact with it more than a couple times per day. Yeah, it takes some…

I already have that routine with uBlock Origin. I don't think NoScript offers all of uBO's functionality, and I certainly won't do the same dance for two extensions, but I'll look into uBO's abilities to specifically block JS.

Makes sense! I use both, uBO just does its thing and I never interact with it. NoScript handles blocking & whitelisting javascript. It's totally possible uBO has a similar feature and I just don't know about it.

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

#554

Earlier quoted context omitted.

You could have a Duration argument though. The parallels of string length with the phrase "How long is a piece of string?"[0] make this apparent/amusing. I'm sure I'm not the first person to think that. [0]: https://en.wiktionary.org/wiki/how_long_is_a_piece_of_string

The `Duration` being a type that implements an interface removing the ambiguity? Like a `DateTime` object does? I think it might be useful to have a function returning a collection of information about text, how many unicode points, how many grapheme clusters, how many syllables, vowels, consonants, special characters… But for performance reasons you probably want separate functions that give you just one of these.

DateTime, Instant, and Duration are totally different things. I believe I was thinking of a class I remember seeing added to java at one point. Time is probably one of the few things in programming that's even more cursed than strings.

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

#555

Earlier quoted context omitted.

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 y…

I would suggest that len works as the article suggests; and "Hello".codepoints gives the behaviour you want.

[dead]

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

#556
post #326

Earlier quoted context omitted.

In Swedish, Å, Ä, and Ö are actual letters of the alphabet, while é is used in foreign words. Like the English dieresis (e.g. in coöperate) is essentially unknown in the US and only occasionally used in England, so doesn't give rise to characters with dieresis on the keyboard.

é is used commonly in names and some words that don't feel foreign. For example the word for idea is written idé . Seems like it's an old loan from greek.

The accent gives away that this is in fact a loan from French

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

#557

Earlier quoted context omitted.

There was no string.length in Swift for a while. Then they added one that just does what the user expects, get the number of grapheme clusters. If a user figures out that this isn't what they want, they can go use the other length method.

except if it's server swift code, then it doesn't do what the user expects at all

The most common reason I can think of a server wanting the string length is because it's enforcing a character limit in some field, in which case it does what the user expects. You aren't often manually managing memory in Swift. On top of that, Swift on server is probably rare to begin with.

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

#558

Earlier quoted context omitted.

é is used commonly in names and some words that don't feel foreign. For example the word for idea is written idé . Seems like it's an old loan from greek.

The accent gives away that this is in fact a loan from French

I guess it's time to learn to use some real swedish words then and not the foreign ones. Bye idé, hello hugskott. (Hug/håg = mind, skott = shot)

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

#559
post #263

Earlier quoted context omitted.

Thanks. Some alphabets have precomposed ligatures that aren't really letters, like old German alphabets with tz, ch, ss (I only know how to type the last one, ß, because the others have died out over the last hundred years). Actually in German (at least) ä, ö and ü really are actually ligatures for ae, oe, and ue -- the scribes started to write the E's on their sides above the base letters, and over time the superscr…

> old German alphabets with tz, ch, ss (I only know how to type the last one, ß, because the others have died out over the last hundred years) They still ꜩ on some German street signs. I can't find ch in Unicode though (could just be my old eyes).

You sent me on an enjoyable wild goose chase but it appears that only ß and ff are in unicode: tz, ch, ck have to be handled completely in rendering.

I have my music teacher's German schoolbook from around 1915 and it lists them all as letters (the whole book is in Fraktur). I have various old books in Fraktur and once could read them. I imagine that if I sat down and tried to read one it would come back, but at the moment I have to thin a little to read just the titles!

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

#560
post #172

Earlier quoted context omitted.

A couple of cases I'm aware of... * Coding ligatures often display as a single glyph (maybe occupying a single-width character space, or maybe spread out over multiple spaces), but are composed of multiple glyphs. The ligature may "look" like a single character for purposes of selection and cursoring, but it can act like multiple characters when subject to backspacing. * Similarly, I've seen keyboard interfaces for v…

I've always felt ligatures that condense two or more glyphs into something that takes up the space of only one in a monospace font are going beyond what a font should handle and into the realm of what an editor should do. I have several such visual substitutions set up in my .emacs but I don't use fonts that do them on their own.

What about ligatures that make ASCII characters display differently when in proximity, but still use the same number of columns?

For example, when == is written, connect them to be a 2 column wide = instead.

Or when === is written, display a three column equals sign, but it's three bars instead of two.

Post reply on HN