News for hackers. Stuff that matters.
Re:Why can't you reverse a string with a flag emoji? by yoyohello13 on Thursday January 27, 2022 @02:36PM (#30105200)
Maybe I'm missing some prerequisite knowledge here, but why would I assume `flag="us"` is an emoji? Looking at that first block of code, there is no reason for me to think "us" is a single character.

Edit: Turns out my browser wasn't rendering the flags.

Re:Why can't you reverse a string with a flag emoji? by happytoexplain on Thursday January 27, 2022 @02:48PM (#30105407)
In Windows Chrome, it doesn't render the emoji for me. In Android Chrome, it renders a flag emoji - not the raw region indicators (which look like the letters "u" and "s").
Re:Why can't you reverse a string with a flag emoji? by greenyoda on Thursday January 27, 2022 @02:43PM (#30105327)
In my browser (Firefox on Windows), the thing between the quotes in the first block of code looks like a picture of the US flag cropped to a circle, not like the characters "us".
Re:Why can't you reverse a string with a flag emoji? by yoyohello13 on Thursday January 27, 2022 @02:52PM (#30105467)
Ah I see, I just opened it in firefox. It looks like some JS library is not getting loaded in Edge. The author was talking about "us", "so", etc. looking like one character and I thought I was going crazy, lol.
Re:Why can't you reverse a string with a flag emoji? by jfk13 on Thursday January 27, 2022 @03:51PM (#30106456)
I don't think that's about a JS library. Firefox bundles an emoji font that supports some things -- such as the flags -- that aren't supported by Segoe UI Emoji on Windows, so it has additional coverage for such character sequences.
Re:Why can't you reverse a string with a flag emoji? by yoyohello13 on Thursday January 27, 2022 @03:54PM (#30106494)
That makes sense. I saw a failure to load a JS module in the console and assumed that was part of the problem.
Re:Why can't you reverse a string with a flag emoji? by masklinn on Thursday January 27, 2022 @03:48PM (#30106418)
There should not be any JS involved though, only a font able to render these grapheme clusters.

Do you see the US flag after "copy and paste this emoji" on https://emojipedia.org/flag-united-states/?

Re:Why can't you reverse a string with a flag emoji? by bialpio on Thursday January 27, 2022 @03:33PM (#30106149)
Reminds me of an image that renders differently on Macs (https://www.bleepingcomputer.com/news/technology/this-image-...), I bet it'd make for a fun conversation that could make the participants question their sanity. :-)
Re:Why can't you reverse a string with a flag emoji? by da12 on Thursday January 27, 2022 @03:04PM (#30105626)
A whole lesson in Unicode in itself right there with your experience, haha!
Re:Why can't you reverse a string with a flag emoji? by ljm on Thursday January 27, 2022 @05:33PM (#30107912)
If it's Windows, it doesn't actually use flags for those emojis, it renders a country code instead. If it wasn't supported you would just see the glyph for an unknown character.

The reason was because they didn't want to be caught up in any arguments about what flag to render for a country during any dispute, as with, e.g. the flag for Afghanistan after the Taliban took control.

Re:Why can't you reverse a string with a flag emoji? by kingcharles on Thursday January 27, 2022 @06:04PM (#30108315)
Do you have a citation for that? I suspected it was because of the political issues, so I tried hunting down the reason one day and came up blank.

[Microsoft had this same issue with the timezone map in Windows. The early versions were cool and had country borders, but then I think it was India/Pakistan threw a fit and it was simplified to take the borders out]

Re:Why can't you reverse a string with a flag emoji? by Benlights on Thursday January 27, 2022 @02:59PM (#30105554)
I had the same issue when I read the article, I kept on getting stuck and asking myself what I was missing.