Live data from Hacker News

Why can't you reverse a string with a flag emoji?

davidamos.dev

241–247 of 247 posts

Re: Why can't you reverse a string with a flag emoji?

#241
post #236

Earlier quoted context omitted.

Boy, that's implicitly a good question... when's the last time I "reversed" a string, on purpose, for something useful? It took me a bit, but I think I have an answer. It's about 15 years ago. I didn't actually do the original design, but I perpetuated it and didn't remove it. We reversed domain name strings (which, given that they are a subset of ASCII, actually is a well-defined operation) so that the DB we're usin…

Right - any case where you are reversing a string as part of some other operation you will have some goal in mind that is not simply 'produce the reverse of any arbitrary string'. Even if your goal is doing something like printing the crossword puzzle answers backwards at the bottom of the page, you have a tightly constrained set of possible characters so you can literally just throw an error if someone asks you to r…

"reversing the sequence of those parts and reassembling the string from the components in reverse order"

Given that this was Perl and that's a small chunk of code, it's probably what I would have done in the same circumstance, but given that it already existed it wasn't worth shipping a migration out to the field with a new version. Generally humans didn't consult this table anyhow.

But it was good for a couple of good "wtf is that" faces from other developers the first time they look at the DB, if nothing else. They get it pretty quickly; the preponderance of "moc." and "ude." gets to be a dead giveaway pretty quickly, especially combined with some popular names ("moc.elgoog" almost sounds like a real domain Google might register someday). But still fun if you catch their face at the right moment.

Re: Why can't you reverse a string with a flag emoji?

#242
post #11

Earlier quoted context omitted.

Reversing a string is still meaningful. Take a step back outside the implementation and imagine handing a Unicode string to a human. They could without any knowledge look at the characters they see and produce the correct string reversal. There is a solution to this which is to compute the list of grapheme clusters, and reverse that. https://unicode.org/reports/tr29/

UAX #29 is insufficient: at the very least, you must depend on collation too. In Norwegian, “æ” is a letter, so I believe (as a non-speaker) that they would reverse “blåbærene” to “eneræbålb”; but in English, it’s a ligature representing the diphthong “ae”, and if asked to reverse “æsthetic” I would certainly write “citehtsea” and consider “citehtsæ” to be wrong. (And I enjoy writing the ligature; I fairly consistent…

Interesting addendum on the matter of reversing “æsthetic”: I asked my parents what they reckoned, and they both went the other way, reckoning that if you wrote æ in the initial word it should stay æ; my dad said he wouldn’t write it that way in the first place, but that if you’ve written it that way you were treating æ as a letter more than just a way of drawing a certain pair of letters. In declaring otherwise, I was using the linguistic approach, which acknowledges æ as a ligature of the ae diphthong from Latin, being purely stylistic and not semantic. And so we see still more how these things are approximations and subjective.

Re: Why can't you reverse a string with a flag emoji?

#243
post #178

Earlier quoted context omitted.

Have emoji not become part of our writing structure though? A decent percentage of online chats and comments, especially on social networks, includes at least one emoji that couldn't be easily or accurately represented in the regular written language.

Recently implementers of unicode have censored the gun emoji in a way that changes the meaning of many existing online chats and comments. So you can't easily or accurately represent things even with unicode. Emoji have never been effective or consistent at conveying meaning; at best they convey something to someone in the same subculture and time period, and often not even that. Given that unicode implementers are o…

> Emoji have never been effective or consistent at conveying meaning; at best they convey something to someone in the same subculture and time period

Isn't that the same with all words though? Think how much English usage changes in a generation. For instance, my girlfriend will use the term "I'm dead!" in a similar context to where I would say "LOL" and where my father would have said "What the fuck is loll?"

Re: Why can't you reverse a string with a flag emoji?

#244
post #44

Interestingly, on my phone the so-called flag is not a flag at all, but "US" in outline. So python behaves as expected: the 2 character string, when reversed, becomes "SU". Similar stuff happens with the other "flag" strings. I'm sure emojis in my phone are outdated. I'm not sure how that affects whether I see a flag or letters.

Out of interest, what phone and browser? The only platform I've seen that doesn't render the flags is Windows.

An android phone from 2014, with a year out of date chrome.

To update chrome, I'd have to give it permission to access my contacts. That ain't happening. (Phone OS is too old for per-app permissions)

Re: Why can't you reverse a string with a flag emoji?

#245
post #178

Earlier quoted context omitted.

Recently implementers of unicode have censored the gun emoji in a way that changes the meaning of many existing online chats and comments. So you can't easily or accurately represent things even with unicode. Emoji have never been effective or consistent at conveying meaning; at best they convey something to someone in the same subculture and time period, and often not even that. Given that unicode implementers are o…

> Emoji have never been effective or consistent at conveying meaning; at best they convey something to someone in the same subculture and time period Isn't that the same with all words though? Think how much English usage changes in a generation. For instance, my girlfriend will use the term "I'm dead!" in a similar context to where I would say "LOL" and where my father would have said "What the fuck is loll?"

There's a spectrum. Subculture-specific slang changes quickly, but most words have a longer lifetime; reading Chaucer today is difficult but doable. Given that we don't encode words but only letters, for English you have to go back to the disappearance of þ to get a change that's relevant to text encoding. Emoji shift faster and are less effective at conveying meaning than any "real" language.

Re: Why can't you reverse a string with a flag emoji?

#246

Earlier quoted context omitted.

> were replaced with "equivalent" Greek or Cyrillic one The subset of equivalent letters, or different ones? If they looked the same, it wouldn't bother me if the letters in the center were a single codepoint between European languages: https://upload.wikimedia.org/wikipedia/commons/8/84/Venn_dia...

The problem is they don't look the same. So imagine, for instance, Я instead of "R" or И instead of "N" (I don't think the sounds are actually equivalent but let's run with it for the sake of example). Not insurmountable. One could still read a text with these substitutions. But it'd be distracting, and extra detrimental for people who don't speak English as their first language.

The ones in the center are in all three sets, they do look the same. The outer areas are out of bounds.

Re: Why can't you reverse a string with a flag emoji?

#247

Earlier quoted context omitted.

You certainly can. `print(String(flag.reversed()))` in Swift reverses emojis correctly.

How does it handle the ASCII examples in https://news.ycombinator.com/item?id=30108184 And more importantly: What is the use case for a reversed string?

The use case: Make an animation, where the text appears starting from the end - for example if you stylize it as vertical text falling from the top.

I think the example shows quite clearly the problem really comes down to dividing the string to logical parts (atoms, grapheme clusters, however you want to call it).

Post reply on HN