5 ms·
Will not reverse languages that are right-to-left by default, such as Arabic or Hebrew. Will not reverse composed ligatures, e.g. ﷺ is synonymous to صَلَّىٰ ٱل
by zyx321 7y ago
Will not reverse languages that are right-to-left by default, such as Arabic or Hebrew.
Will not reverse composed ligatures, e.g. ﷺ is synonymous to صَلَّىٰ ٱللَّٰهُ عَلَيْهِ وَسَلَّمَ, but صَلَّىٰ ٱللَّٰهُ عَلَيْهِ وَسَلَّمَ with a LTR directional override is صَلَّىٰ ٱللَّٰهُ عَلَيْهِ وَسَلَّمَ while ﷺ remains as ﷺ.
Will not reverse 겁 into 벅.
- enriquto 7y agowow, these symbols are awesome! Is it regular arabic or fancy calligraphy stuff? Are there two lines of characters?
- BubRoss 7y agoYou can copy and paste the text
- blattimwind 7y agoSince these are ligatures (though really complex ones) most software consider these as one "character" (try selecting part of the ligature; you can't).
- zyx321 7y agoIt's a fancy calligraphy version of "Peace Be Upon Him" used specifically when referring to the prophet Muhammad. There are a handful similar phrases, mostly religious in nature. The most notable one would be ﷽ "In the name of Allah the merciful and compassionate" AKA the widest single codepoint in all of Unicode.
- seiferteric 7y agoMakes me wonder if we should not have tried to make a single "unicode" and instead had distinct types for each language like EnglishString ArabicString etc. and programmers can handle each case as needed.
- zyx321 7y agoNo. If that's how it worked, how many programs would have Arabic support at all? Everyone would use EnglishString for everything (because that was the example code they copied from StackOverflow) and the whole thing comes crashing down if I enter even just an umlaut.
- seiferteric 7y agoNo, I was thinking of something a little more sophisticated than that. Classes of strings would be sub-classed from others like English would have multiple sub-classes like American, British etc. Each class could have it's own parameters like whether it supports being reversed. You would not necessarily implement just for English. If you were making a palindrome finding app for example, you would only care if the class passed in supports reversing for example. Eventually you could have a language DB library, not so different that the time zone database that can be periodically updated with new rules.
- LyndsySimon 7y agoThat’s a lot of types, regardless of how you define them. Is AAVE a separate “language” from “standard English”? How about Creole? Is that French, English, or a distinct language? Is Pennsylvania Dutch/“Low German” German or English? What about Yiddish? Modern Yiddish is an entirely different beast from historical Yiddish. Who is going to be defining the type for Greek? What region and point in history will they be using for a reference? Does GermanString contain Eszett? If so, is it a separate code point or interchangeable with “ss”? Is there logic that defines when “ss” should be represented as an Eszett and when it should be rendered as “ss”? No, I think Unicode is the right approach. You get all the code points you might need and logic for processing them as glyphs. Leave everything else up to the application.
- zokier 7y agoUnicode is structured into planes and furthermore into blocks: https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilin... So you can actually separate them if you want pretty easily
- voidumbrella 7y agoWhy would reversing 겁 into 벅 make sense? If I asked someone to reverse the string 예제, I'd expect 제예 and not ㅔ졩.
- zyx321 7y agoI have to admit I'm not a native Korean speaker. Are you? The issue brought up by the article is that neither makes sense. Reversing a string is not a semantically meaningful operation.
- voidumbrella 7y agoYes, while 겁 is made out of ㄱ ㅓ ㅂ, native Korean speakers would expect a string reversing function to operate on precomposed syllable codepoints rather than breaking them into the components. I do agree with the overall point; just thought this specific example was a bit odd.
- mistersquid 7y agoYour point is well-taken with Hangul, but what about, say, English? Does the string-reversing function receive "English" and output "hsilgnE" or "lishEng"? What if the string matches no known words (e.g. alphanumeric passphrase)? What if the string represents a single syllable (e.g. "was")? Thinking of strings as connected to vocalized syllables only makes sense with strings meant to represent syllables, sure, but even that can lead to counterintuitive results. I know you weren't defending the idea of a string-reversing function, but your objection is not exactly grounded in principle, either. That is, when you ask > Why would reversing 겁 into 벅 make sense? one could easily say, why wouldn't that literal reversal of the phoneme make sense? I understand it doesn't, but that's the problem with Unicode reversing-functions.
- cryptonector 7y agoHangul is phonetic, but with letters arranged into syllabic symbols. In Spanish there's a gibberish construction where you reverse syllables ("al vesre", meaning, "al revés", which means "backwards"). Reversing text makes little sense except as an interview trick question, I guess, but if you must make sense of it, then reversing syllables makes more sense than going further. BTW, you can reverse Unicode (in any UTF), so long as you don't really care about the semantics of the result -- if all you want to do is reverse the codepoints, you could. After all, it is an interesting programming interview trick question, though admittedly then "you can't really" answer is more fun because you get to talk about glyphs and ligatures and so on, and natural language, thus demonstrating your mastery to the person who was trying to trick you.
- jonahx 7y agoJust so I understand, the original question has no answer because there is not a 1-1 correspondence between code points and glyphs? If there were, it would be trivial to solve. But instead Unicode has formatting and control code points and that complicates everything? Is that the gist of it or is there more?
- dahfizz 7y agoReally, the problem is the question itself. A more specific requirement such as "make all the glyphs appear in reverse order" makes it a much easier problem (still tricky and full of edge cases, but conceptually simple). "Reverse" is just too ambiguous when dealing with Unicode.