News for hackers. Stuff that matters.
Re:Writing UTF-8 Programs in Plan 9 by lifthrasiir on Sunday February 27, 2022 @06:08AM (#30487195)
It is clear that the article simply translates K&R exercise into runes without a consideration, but I should note that reversing a codepoint (or rune) sequence is not identical to reversing the human-readable text. The hiragana example is outright wrong because no Japanese would think `ゃき` (codepoint-wise reversal of `きゃ` kya) as a meaningful Japanese text.
Re:Writing UTF-8 Programs in Plan 9 by ynfnehf on Sunday February 27, 2022 @06:26AM (#30487302)
How is that any different than reversing the English digraphs? "th", "ch", "wh", etc. Reversing English doesn't usually produce something meaningful either.
Re:Writing UTF-8 Programs in Plan 9 by nerdponx on Sunday February 27, 2022 @09:56AM (#30488988)
Some languages consider (or used to consider) "ch" as a single "letter".
Re:Writing UTF-8 Programs in Plan 9 by lifthrasiir on Sunday February 27, 2022 @06:32AM (#30487332)
You are entirely correct that that K&R exercise is flawed in the first place. I'm more concerned about the language-specific rules for (somehow) reversing a text therefore.
Re:Writing UTF-8 Programs in Plan 9 by donatj on Sunday February 27, 2022 @06:32AM (#30487328)
Can you explain further, I’m not sure I understand the objection. Doesn’t any language backwards become unintelligible to its readers? Doesn’t seem specific to Japanese.

How would you wish `ゃき` to reverse if not `きゃ`?

https://emoji.boats/s/きゃ

Seeing as they are both are normal runes with no modifiers attached, I don’t know what alternative there would be?

Re:Writing UTF-8 Programs in Plan 9 by lifthrasiir on Sunday February 27, 2022 @06:38AM (#30487361)
I think my usage of the word "meaningful" was very much generous. Let me clarify my intention then: the "correctly" (that is, preferred by speakers) reversed text is unlikely to have a meaning, but it is still likely to adhere the language's phonotactic rules. ゃ (small ya, as opposed to ordinary や ya) is something you never expect to be the first character because it modifies the preceding syllable. The use of such small characters (すてがな sutegana) as the first character in words is very limited in Japanese.
Re:Writing UTF-8 Programs in Plan 9 by thewakalix on Sunday February 27, 2022 @07:02AM (#30487542)
I don’t think English is such that every sequence of letters is a valid encoding of phonemes, either.
Re:Writing UTF-8 Programs in Plan 9 by charcircuit on Sunday February 27, 2022 @07:12AM (#30487626)
I think it is only you who have a problem with it. Writing Japanese horizontally has only been a thing for about 100 years. About 100 years ago the direction Japanese was written horizontally was mixed between left to right and right to left.

Writing Japanese reversed aka right to left isn't a weird concept.

Re:Writing UTF-8 Programs in Plan 9 by lifthrasiir on Sunday February 27, 2022 @08:14AM (#30488109)
I'm aware that RTL Japanese was a thing. In fact, what you have described is not really RTL; its inline direction is top to bottom and its block direction is right to left [1] while what we typically refer to RTL is about the inline direction. RTL Japanese is actually a specific variation of this TTB/RTL writing where the line itself only consists of a single character. Very rare (typically signages), but it did exist.

But that doesn't mean your RTL text should be preemptitively reversed in the memory, which is exactly what the exercise asks you to do. Historically this was the case for some early character encoding, where the reversed text is called the "visual order" opposed to the "logical order". This caused enough problems that Unicode is now primarily the logical order only, except for a few scripts where the historical visual order is retained (e.g. Thai).

[1] See https://www.w3.org/TR/css-writing-modes-4/#text-flow for more information.