So what was the deal with the Scottish flag?
Why can't you reverse a string with a flag emoji?
41–50 of 247 posts
Re: Why can't you reverse a string with a flag emoji?
#42If someone challenges you to reverse an image, what do you do? Do you invert the colors? Mirror horizontally? Mirror vertically? Just reverse the byte order?
Re: Why can't you reverse a string with a flag emoji?
#43Earlier 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/
Should it reverse a BOM as well or keep it first?
Re: Why can't you reverse a string with a flag emoji?
#44So 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.
Re: Why can't you reverse a string with a flag emoji?
#45Re: Why can't you reverse a string with a flag emoji?
#46Re: Why can't you reverse a string with a flag emoji?
#47I guessed that it would become the USSR flag (US -> SU), but apparently Unicode doesn't define that one! I wonder why. That would have been humorous.
As I understand it, there is no two-letter ISO code for the USSR because when they update the standard they remove countries that no longer exist. In at least one case they have reused a code point: CS has been both "Czechoslovakia" and "Serbia and Montenegro", neither of which currently exist. As a result, two-letter ISO codes are useless for many potential applications, such as, for example, recording which country…
Re: Why can't you reverse a string with a flag emoji?
#48On the challenge front, there are things like á which might be a single code point or two code points (a+´). Then there are the really challenging things like ᾷ where if the components are individual characters, the order of ͺ and ῀ are not guaranteed to be consistent.
Re: Why can't you reverse a string with a flag emoji?
#49Re: Why can't you reverse a string with a flag emoji?
#50But you can, and did, reverse a string. It seems you would need more details, such as a request to reverse the meaning or interpretation of the string, which is what the author is getting at. If someone challenges you to reverse an image, what do you do? Do you invert the colors? Mirror horizontally? Mirror vertically? Just reverse the byte order?
Case in point: a "struct" in languages like C and Rust is literally a specification of how to treat segments of a "string" of contiguous bytes.