4 ms·
This is misinformation. OP's strings are just wrong... >> "\u0308" => "̈" >> "\u00eb" => "ë" >> "noe\u0308l" => "noël" >> "no\u00eb
by ddebernardy 13y ago
This is misinformation. OP's strings are just wrong...
>> "\u0308"
=> "̈"
>> "\u00eb"
=> "ë"
>> "noe\u0308l"
=> "noël"
>> "no\u00ebl"
=> "noël"
His noël examples work just fine if you don't copy/paste the string he posts, and instead type them in like I just did.
If anything, languages are reporting correct reverses and length, since he's really manipulating 5 characters rather than four.
- enko 13y agoCongratulations, you've discovered unicode composition! 2.0.0p247 :045 > Unicode::compose("e\u0308").unpack('U').first.to_s(16) => "eb" 2.0.0p247 :046 > Unicode::compose("\u00eb").unpack('U').first.to_s(16) => "eb" 2.0.0p247 :047 > Unicode::decompose("e\u0308").unpack('U').first.to_s(16) => "65" 2.0.0p247 :048 > Unicode::decompose("\u00eb").unpack('U').first.to_s(16) => "65" I presume the ones you pasted in were changed by the browser. His examples are not wrong at all, indeed how can a string be "wrong"?
- ddebernardy 13y agoHis example is "wrong" in the sense that you cannot reasonably complain that "noe¨l" gets reversed to "l¨eon" and put the "¨" part on top of the "l" when it does — which seems entirely correct. Or for that matter, that the string's length is 5 when there are indeed 5 characters. As for being changed by the browser, the latter (or rather the OS) copied what there was, and the OS pasted it verbatim insofar as I can tell.