Javascript can't reverse strings
-
-
-
Same happens for American cities.
Woburn - Woo-burn
I've previously mentioned
Gloucester - Glowstah
Worcester - Wustah
Dorchester - Dorchestah
Wooster - Woostah
Braintree - Armpit[1][1] little joke, there.
-
Don't forget:
Waltham - Walt ham
-
-
-
Waltham - Walt ham
Unless it's 'Waltham Cross` in which case it's 'Wall-tham'
Close (~2mi) by is 'Cheshunt' which is 'Ches-unt'
-
Waltham Cross
Or Walthamstow/Waltham Forest. Unless I was just saying that wrong for the year and a half I lived there...
-
Unless I was just saying that wrong for the year and a half I lived there...
No you weren't. I grew up in the area.
-
Sorry to hear that
-
Witham (Essex) - Wit-em
South Witham (Lincolnshire) - South With-em
-
-
I guess that's where all the British colonists who went to Australia came from ..
-
-
Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch, though even the Welsh think that one's just plain silly. (And it is narrower due to the different proportion of letters…)
-
…and it breaks the OneBox
Well, sort of.
-
useless IPA
You watch your dirty mouth!
-
-
Philistine! Uncultured swine!
-
-
the beer capital of the world
I don't know where that is. Google suggests Milwaukee, there's no way that can be right. I'd go with Munich or Prague. If you're in the US, maybe Portland or San Francisco.
-
nope.
-
-
-
@aliceif what did you do to my post? Now it has an edit history but the two revisions seem identical?
<curious>
-
I fixed the link.
You hadhref=""http...
in there, so I moved the second quotation mark to the proper place.
-
Thanks, then :<smiling>)
-
strfry()
considered <del>harmful</del><ins>not random</ins>Somebody should add a bug about
strfry()
messing up utf-8 strings. I'm sure it'd be appreciated.
-
http://craftystap.com/wp-content/uploads/2013/01/IPA.jpg
That's the IPA you need to pronounce some of those Welsh place names.
-
strfry() considered harmfulnot random
Ulrich is quite well known in the glibc world for being a dick.
-
Ugh! I've known about that function for years (and considered it silly) but only just now did I misread it as “stir fry” and so work out why it was called what it was.
-
was there a problem with [code]"Å, Andøy".split("").reverse().join("");[/code] which works fine in my browser at least [code]"yødnA ,Å"[/code]
-
Probably splits on characters not bytes. I'll bet combining characters go wrong though.
-
I'll bet combining characters go wrong though.
It's a normal failure mode for combining characters. If you're lucky, normalising to NFC first will help, but not everything normalises. (The fact that not all combinations of accent and character have their own codepoint is why we have combining characters in the first place.)
-
It's a normal failure mode for combining characters. If you're lucky, normalising to NFC first will help, but not everything normalises. (The fact that not all combinations of accent and character have their own codepoint is why we have combining characters in the first place.)
So maybe the real solution is to stop trying to reverse strings in the first place?
-
I'd go with Munich or Prague
Prague (Praha) might be capital of binge drinking, but the famous beer is brewed in Pilsen (Plzeň).
-
```
"Å, Andøy".split("").reverse().join("");
"yødnA ,Å"Oh, that works fine. JavaScript strings are encoded in [nonvalidated-wannabe-UTF-16][WTF-8], so basic plane single-codepoint glyphs work just fine. But watch this: [code] > "bác".split("").reverse().join("") < "cáb" > "bác".split("").reverse().join("") < "ćab" [/code] Yup, that's right, the acute accent moved. That's because the first string is composed normal form, so the "á" is a single codepoint, but the later is decomposed normal form, so the "á" is "a" + " ́" and those get treated separately. And then there is [code] > "💩".split("").reverse().join("") < "��" [/code] clearly showing that the encoding is not really UTF-16, because not only are lone surrogates not rejected, surrogates are not handled at all. More details in the [WTF-8] description. @dkf <a href="/t/via-quote/7504/139">said</a>:<blockquote>normalising to NFC</blockquote> Except JavaScript does not come with unicode normalization function. @VinDuv <a href="/t/via-quote/7504/140">said</a>:<blockquote>So maybe the real solution is to stop trying to reverse strings in the first place?</blockquote> Given that in many languages it's not even clear what it would mean to reverse string I agree. Reversing strings is stupid. [WTF-8]: https://simonsapin.github.io/wtf-8/
-
-
-
How would that work with Unicode I wonder
-
-
@acalia said:
"Wooster"
That's just Worcester.
Although Worcestershire sauce is always pronounced Worcester sauce, just to confuse the issue further.
Now that you've got the hang of the ~cester rule in English placenames, you shouldn't have any problem with Cirencester, right?
[spoiler]si-ren-ses-ter, of course. What would the world be coming to if British English had a consistent pronunciation of anything?[/spoiler]
-
Can we just switch to map grid references or something?
City 17. That was fine. Not a nice place mind you, but at least it was easy to
findavoid!
-
> "💩".split("").reverse().join("")
< "��"Why is there even a unicode for 'happy pile of shit'?
-
The usual answer to questions like this is "Japan"
-
Why is there even a unicode for 'happy pile of shit'?
Same reason Egyptian hieroglyphics are in Unicode?
-
For compact writing of "the horned viper shits on two reeds"?
-
[code]"S̘̞̰̘̮̪̲̪̣͉̰͔͔̮̩̱̬͍͆̆ͫͤͩ̓ͧͪ̃͜ͅo̶̧̲̫̹͉̺̫̬̰̩̩͇̙̣͓ͯ͗͊ͪ̐̚ ̷̴͙̘͚͇̬̳̦̺͙̱͚̦̖͎̯̗͗͐̆͊ͣͪ̈́̽ͩ́y̶̛͗ͧ̆͒ͭ̑̒͗͒̌̏ͦ͜͏̮̜̭̻̦͔̣̝̙̼͟ơ̵̪͉̫̮̣͉̗̟̥̞̳̠̮̪̟ͮͧ͐ͥ̋ͯͫ̔ͨͭͭ̑̌ͬ̿ͣ̄ͩ̋͜u̡͙̝̻̥̰̯̠̘̗̺̔̀ͯ͑͌̉͢'̡̩̦̺̮͔̤̯̳͕̞̜͔̝̗̿̓ͤ̃ͥ͂̀͗̽ͨ͑͐ͬ͐̓͋͑ͬ̄̕r͚̤͕̠͚̙͍̞̺ͣ̈̿ͤ̏̍ͨ̀̕ͅê̝̪̘̘̤͓͚̼͈ͬ̆ͥͭ̅̎ͮ̆̏̿̌ͩͩͦ͒̈̅̑̀ ̣̝̲̫̩̖̖̹̩̻̱ͫ͊̇͒̂̓ͥͧ̈͌̍ͨ̓ͪͤ͢͠s̵̼̩͔͔̘̰͉͑̾̑̓̾̋̍́͂͒̀́ą̢͈͓̖̂̔̉͗͋̐͋̑͐ͤ̽̎́ͅỹ̵͌̿ͪ͏̡̬̟̼͕͚͙͖͍̟i̺͔͍̣̗̮̣ͩ̏̃̉̉̎ͩ͗͛͊ͯͬ͐ͫͫ̓̀͢͝n̴̢̺̪̣̳̻͉̫̽ͨ̍́̅ͭ̐̽ͣ̾̕g̡̊͛̋ͮͩ͋ͥͬ̓ͫͧ̆ͨ̎̌͆̽͏͍̭̯̠̝̰͍̰͔͈̳̬̫͔̯̣͖ͅ ̐ͨ͒ͪ̀ͥ̐̈̾ͯ̌̎͜͞͏̱͔̬͎̳͓͚̯̭̦͔̮̬̤t̴̵̨̧̮̼͎̠̣͎̘̲̝͙̝͑ͯͨ̄ḩ̵̘͔̤̠̗͎̋͋̍̈́̾ͥͪͣͬ͗́̄̌̚͟i̽ͣͣ̉ͫ̐̉͗͐̋̾̎̓̕͏҉̪͔͕̝̬͕̫͟͞s̨̢͉͎͔̝͉͔͆̏̏͒̃̚͘͝ ̴̡͊̔͑̾̓̈́͆̂̃̽ͤ͐͟͢͏͖͖̜̹͉͕̙͔̩̼̮͓͍̲̮̺̹ͅw̧̨̏̇͂̑̓͛͐ͤ͐ͥ̎̍͡҉͔̹̟̮̞̹̰͕̤̟͉̺̳͇̦̤̝ọ̧̱̪̋ͥ̈́ͫ́̊̍͐̊͑̋ͨͯ̈̓͛͢͞n̢̢̤̬͇̪̼͙͍̝̞̬̖̦͉̭̯͕̋̀͌̏́ͪ̓̄̋͗ͤͫͦ̾̅̚'̴̱͍̣̯̼͓͓̰̯̥̱̰͍́̑̉͝͝t̥̹̤͔̼͆ͣ̉̑͐̆ͩ̋̾̓̈̌͛̾ͣ̃ͭ̚͟͞ ̨̧̰̻̣͚͇̠̳̹͚̻̣̗̻̪̺̲̺̘̝͗̌͛͑͛̅̎͆͢r̡͋͋ͤ̄͆͗̆҉̖̗͚̲̮͈͕̙̙̗͔̱̘͉̮eͦͯ͗̎͛̊̊̐̇̎ͨ̒̍̌҉̷͘҉̛̟͉̬̱͚v̶̧̥̹̻̪͚̈ͣ̓͐ͯ̍ͬ̀̔͑̀͑̿̓ͬ͐ͨ͟͝ȩ̴̛̣̼͍̫̻̠͚̪̜̞̪̙̑͆ͬ̐̄ͬͨͨ̓̃ͬ̎̈́̚̚r̵͇̠̱̪̝͍͍͉̂̋̓ͩ̒̆̄͑̇͐ͤ̌̚̚͠s̎ͨͦ̅̃̆͒ͫ̿҉̸̤̣̫̼̳͇̬͔̗͉̙̹̩͎̤e͗ͪ͐̄͑͐̂̂̏͌̄̓̍̃͏̵̲̞̺̫͘ ̈́̐́͊͋͘͏̮͔̠͙̖͇̗̲͖̩̣̠̙̰͕v̵̶̧̡͉͇̱̜̖̙͓̝̘̐ͨ̇ͫę̶̢͍͓̤͎͇̣̥̒ͨ͒͂ͥ͠͠r̵̢̭̻̳̦̳͖̣̩͍̟̄͆̇ͧͪ̀͆̅ͥ͟͢͠y̵̡̱̝͚̘ͪ̉ͮ̃ ̵͍͙͖͚̲̻̮̪̞̙̱ͭ̅̊ͫ̊̐̐̇̀̅ͦ͌͂̔ͫͦ̔̚͜͠͡w̛̳͉͇͎̘̩̪͙̟̠̜̫̅ͯ̌̽ͯͩ̽͂̑̏̽̊̑ͮͩ̀͠ȩ̨͎̤̱̬̮͓̽͌ͯ̆ͦ̐l̡̰̰̤̖͔̮͉̞̊͐͋͗ͧͫ̎̚͝͠ͅļͬ̔ͦ̔͌ͩ̔͜҉҉̠̪̟͍̲͎̝͖̦͎̼͚̮̥̻̹͜ͅ?̶̴̡͍̥̱͚̲̝͚̰͖̘͉̌ͤ̾́ͦͯ͆̍͆̂ͪ̉͒͑̓̌ͅ".split("").reverse().join("");
"̴̶̡͉̘͖̰͚̝̲͚̱̥͍̌̓͑͒̉ͪ̂͆̍͆ͯͦ́̾ͤ̌ͅ?̹̻̥̮͚̼͎̦͖̝͎̲͍̟̪̠͜ͅ҉҉̧̔ͩ͌̔ͦ̔ͬ͜l̡̞͉̮͔̖̤̰̰̎ͫͧ͗͋͐̊̚͠͝ͅl̨̧͓̮̬̱̤͎̐ͦ̆ͯ͌̽è̛̫̜̠̟͙̪̩̘͎͇͉̳ͩͮ̑̊̽̏̑͂̽ͩͯ̽̌ͯ̅͠w̵̱̙̞̪̮̻̲͚͖͙͍̔ͦͫ̔͂͌ͦ̅̀̇̐̐̊ͫ̊̅ͭ̚͜͡͠ ̵̡̘͚̝̱̃ͮ̉ͪy̵̢̟͍̩̣͖̳̦̳̻̭ͥ̅͆̀ͪͧ̇͆̄͢͟͠r̶̢̨̥̣͇͎̤͓͍ͥ͂͒ͨ̒͠͠e̶̵̡̧̘̝͓̙̖̜̱͇͉ͫ̇ͨ̐v͕̰̙̠̣̩͖̲̗͇̖͙̠͔̮͏͋͊́̐̈́͘ ̵̫̺̞̲͘͏̃̍̓̄͌̏̂̂͐͑̄͐ͪ͗e̸̤͎̩̹̙͉̗͔̬͇̳̼̫̣̤҉̿ͫ͒̆̃̅ͦͨ̎š̵͉͍͍̝̪̱̠͇ͤ͐̇͑̄̆̒ͩ̓̋̂̚̚͠ŗ̴̛̙̪̞̜̪͚̠̻̫͍̼̣̈́̎ͬ̃̓ͨͨͬ̄̐ͬ͆̑̚̚ȩ̶͚̪̻̹̥ͨ͐ͬ̓̿͑̀͑̔̀ͬ̍ͯ͐̓ͣ̈͟͝v̛͚̱̬͉̟҉̷͘҉̌̍̒ͨ̎̇̐̊̊͛̎͗ͯͦe̮͉̘̱͔̗̙̙͕͈̮̲͚̗̖҉̡̆͗͆̄ͤ͋͋ŗ̨̝̘̺̲̺̪̻̗̣̻͚̹̳̠͇͚̣̻̰͆̎̅͛͑͛̌͗͢ ̼͔̤̹̥ͭ̃ͣ̾͛̌̈̓̾̋ͩ̆͐̑̉ͣ͆̚͟͞t̴͍̰̱̥̯̰͓͓̼̯̣͍̱̉̑́͝͝'̢̢͕̯̭͉̦̖̬̞̝͍͙̼̪͇̬̤̅̾ͦͫͤ͗̋̄̓ͪ́̏͌̀̋̚ņ̪̱̣͛̓̈ͯͨ̋͑̊͐̍̊́ͫ̈́ͥ̋͢͞o̝̤̦͇̳̺͉̟̤͕̰̹̞̮̟̹͔҉̨̧̍̎ͥ͐ͤ͐͛̓̑͂̇̏͡w̹̺̮̲͍͓̮̼̩͔̙͕͉̹̜͖͖ͅ͏̴̡͐ͤ̽̃̂͆̈́̓̾͑̔͊͢͟ ̢̨͔͉̝͔͎͉̃͒̏̏͆͘̚͝s̫͕̬̝͕͔̪͟͞҉͏̓̎̾̋͐͗̉̐ͫ̉ͣͣ̽̕ǐ̵̧͎̗̠̤͔̘̄́͗ͬͣͪͥ̾̈́̍͋̋̚͟ḩ̵̴̨̝͙̝̲̘͎̣̠͎̼̮̄ͨͯ͑t̤̬̮͔̦̭̯͚͓̳͎̬͔̱͏̎̌ͯ̾̈̐ͥ̀ͪ͒ͨ̐͜͞ ͖̣̯͔̫̬̳͈͔̰͍̰̝̠̯̭͍ͅ͏̡̽͆̌̎ͨ̆ͧͫ̓ͬͥ͋ͩͮ̋͛̊g̴̢̫͉̻̳̣̪̺̾ͣ̽̐ͭ̅́̍ͨ̽̕ṇ̮̗̣͍͔̺̀̓ͫͫ͐ͬͯ͊͛͗ͩ̎̉̉̃̏ͩ͢͝i̡̟͍͖͙͚͕̼̟̬͏̵ͪ̿͌̃ý̢̨̖͓͈̎̽ͤ͐̑͋̐͋͗̉̔̂ͅá̵͉̰̘͔͔̩̼̀͒͂́̍̋̾̓̑̾͑s̱̻̩̹̖̖̩̫̲̝̣ͤͪ̓ͨ̍͌̈ͧͥ̓̂͒̇͊ͫ͢͠ ͈̼͚͓̤̘̘̪̝̀̑̅̈͒ͦͩͩ̌̿̏̆ͮ̎̅ͭͥ̆ͬ̂è̺̞͍̙͚̠͕̤͚ͨ̍̏ͤ̿̈ͣ̕ͅr̡̗̝͔̜̞͕̳̯̤͔̮̺̦̩̄ͬ͑͋̓͐ͬ͐͑ͨ̽͗̀͂ͥ̃ͤ̓̿̕'̡̺̗̘̠̯̰̥̻̝͙̉͌͑ͯ̀̔͢ư̵̟̪̮̠̳̞̥̟̗͉̣̮̫͉̪̋ͩ̄ͣ̿ͬ̌̑ͭͭͨ̔ͫͯ̋ͥ͐ͧͮ͜o̼̙̝̣͔̦̻̭̜̮͟͏̶̛ͦ̏̌͒͗̒̑ͭ͒̆ͧ͗͜ý̴̷̗̯͎̖̦͚̱͙̺̦̳̬͇͚̘͙ͩ̽́̈ͪͣ͊̆͐͗ ̶̧͓̣̙͇̩̩̰̬̫̺͉̹̫̲̐ͪ͊͗ͯ̚õ͍̬̱̩̮͔͔̰͉̣̪̲̪̮̘̰̞̘ͪͧ̓ͩͤͫ̆͆͜ͅS"[/code]
Yeah, that doesn't work
-
string Zalgo = @"S̘̞̰̘̮̪̲̪̣͉̰͔͔̮̩̱̬͍͆̆ͫͤͩ̓ͧͪ̃͜ͅo̶̧̲̫̹͉̺̫̬̰̩̩͇̙̣͓ͯ͗͊ͪ̐̚ ̷̴͙̘͚͇̬̳̦̺͙̱͚̦̖͎̯̗͗͐̆͊ͣͪ̈́̽ͩ́y̶̛͗ͧ̆͒ͭ̑̒͗͒̌̏ͦ͜͏̮̜̭̻̦͔̣̝̙̼͟ơ̵̪͉̫̮̣͉̗̟̥̞̳̠̮̪̟ͮͧ͐ͥ̋ͯͫ̔ͨͭͭ̑̌ͬ̿ͣ̄ͩ̋͜u̡͙̝̻̥̰̯̠̘̗̺̔̀ͯ͑͌̉͢'̡̩̦̺̮͔̤̯̳͕̞̜͔̝̗̿̓ͤ̃ͥ͂̀͗̽ͨ͑͐ͬ͐̓͋͑ͬ̄̕r͚̤͕̠͚̙͍̞̺ͣ̈̿ͤ̏̍ͨ̀̕ͅê̝̪̘̘̤͓͚̼͈ͬ̆ͥͭ̅̎ͮ̆̏̿̌ͩͩͦ͒̈̅̑̀ ̣̝̲̫̩̖̖̹̩̻̱ͫ͊̇͒̂̓ͥͧ̈͌̍ͨ̓ͪͤ͢͠s̵̼̩͔͔̘̰͉͑̾̑̓̾̋̍́͂͒̀́ą̢͈͓̖̂̔̉͗͋̐͋̑͐ͤ̽̎́ͅỹ̵͌̿ͪ͏̡̬̟̼͕͚͙͖͍̟i̺͔͍̣̗̮̣ͩ̏̃̉̉̎ͩ͗͛͊ͯͬ͐ͫͫ̓̀͢͝n̴̢̺̪̣̳̻͉̫̽ͨ̍́̅ͭ̐̽ͣ̾̕g̡̊͛̋ͮͩ͋ͥͬ̓ͫͧ̆ͨ̎̌͆̽͏͍̭̯̠̝̰͍̰͔͈̳̬̫͔̯̣͖ͅ ̐ͨ͒ͪ̀ͥ̐̈̾ͯ̌̎͜͞͏̱͔̬͎̳͓͚̯̭̦͔̮̬̤t̴̵̨̧̮̼͎̠̣͎̘̲̝͙̝͑ͯͨ̄ḩ̵̘͔̤̠̗͎̋͋̍̈́̾ͥͪͣͬ͗́̄̌̚͟i̽ͣͣ̉ͫ̐̉͗͐̋̾̎̓̕͏҉̪͔͕̝̬͕̫͟͞s̨̢͉͎͔̝͉͔͆̏̏͒̃̚͘͝ ̴̡͊̔͑̾̓̈́͆̂̃̽ͤ͐͟͢͏͖͖̜̹͉͕̙͔̩̼̮͓͍̲̮̺̹ͅw̧̨̏̇͂̑̓͛͐ͤ͐ͥ̎̍͡҉͔̹̟̮̞̹̰͕̤̟͉̺̳͇̦̤̝ọ̧̱̪̋ͥ̈́ͫ́̊̍͐̊͑̋ͨͯ̈̓͛͢͞n̢̢̤̬͇̪̼͙͍̝̞̬̖̦͉̭̯͕̋̀͌̏́ͪ̓̄̋͗ͤͫͦ̾̅̚'̴̱͍̣̯̼͓͓̰̯̥̱̰͍́̑̉͝͝t̥̹̤͔̼͆ͣ̉̑͐̆ͩ̋̾̓̈̌͛̾ͣ̃ͭ̚͟͞ ̨̧̰̻̣͚͇̠̳̹͚̻̣̗̻̪̺̲̺̘̝͗̌͛͑͛̅̎͆͢r̡͋͋ͤ̄͆͗̆҉̖̗͚̲̮͈͕̙̙̗͔̱̘͉̮eͦͯ͗̎͛̊̊̐̇̎ͨ̒̍̌҉̷͘҉̛̟͉̬̱͚v̶̧̥̹̻̪͚̈ͣ̓͐ͯ̍ͬ̀̔͑̀͑̿̓ͬ͐ͨ͟͝ȩ̴̛̣̼͍̫̻̠͚̪̜̞̪̙̑͆ͬ̐̄ͬͨͨ̓̃ͬ̎̈́̚̚r̵͇̠̱̪̝͍͍͉̂̋̓ͩ̒̆̄͑̇͐ͤ̌̚̚͠s̎ͨͦ̅̃̆͒ͫ̿҉̸̤̣̫̼̳͇̬͔̗͉̙̹̩͎̤e͗ͪ͐̄͑͐̂̂̏͌̄̓̍̃͏̵̲̞̺̫͘ ̈́̐́͊͋͘͏̮͔̠͙̖͇̗̲͖̩̣̠̙̰͕v̵̶̧̡͉͇̱̜̖̙͓̝̘̐ͨ̇ͫę̶̢͍͓̤͎͇̣̥̒ͨ͒͂ͥ͠͠r̵̢̭̻̳̦̳͖̣̩͍̟̄͆̇ͧͪ̀͆̅ͥ͟͢͠y̵̡̱̝͚̘ͪ̉ͮ̃ ̵͍͙͖͚̲̻̮̪̞̙̱ͭ̅̊ͫ̊̐̐̇̀̅ͦ͌͂̔ͫͦ̔̚͜͠͡w̛̳͉͇͎̘̩̪͙̟̠̜̫̅ͯ̌̽ͯͩ̽͂̑̏̽̊̑ͮͩ̀͠ȩ̨͎̤̱̬̮͓̽͌ͯ̆ͦ̐l̡̰̰̤̖͔̮͉̞̊͐͋͗ͧͫ̎̚͝͠ͅļͬ̔ͦ̔͌ͩ̔͜҉҉̠̪̟͍̲͎̝͖̦͎̼͚̮̥̻̹͜ͅ?̶̴̡͍̥̱͚̲̝͚̰͖̘͉̌ͤ̾́ͦͯ͆̍͆̂ͪ̉͒͑̓̌ͅ"; SC.WriteLine(Zalgo); SC.WriteLine(); char[] split = Zalgo.ToCharArray(); Array.Reverse(split); string reversed = new string(split); SC.WriteLine(reversed);
seems to work OK (ish) in C#
-
Except JavaScript does not come with unicode normalization function.
Stop bringing me problems. Bring me solutions!