Two wrongs don't make a right, but two lefts can take a good whack at it

by Michael S. Kaplan, published on 2009/04/09 14:01 +00:00, original URI: http://blogs.msdn.com/michkap/archive/2009/04/09/9539475.aspx


When you were growing up, you might have had adults try to indoctrinate you with pithy biscuits of nothingness like

Two wrongs don't make a right.

Maybe it was just be, but nonsense like that used to just annoy me.

Thankfully comedians would add to it, with items like

Two wrongs don't make a right, but three rights make a left.

This would not annoy me, because anytime you make fun of something that annoys me, I am entertained.

Now blogs from over three years ago like Just when you think you know a function... have a different lesson. You know, by showing how you could take two U+200f (RIGHT-TO-LEFT MARKER) code points and by prepending your MessageBox text with them, you could make it mirror the MessageBox.

I could have gone for the cute pithy sappy crap and claimed that this proves that

Sometimes two rights make a right.

but I did not because it just doesn't seem all that clever. Maybe I could have said, along the same logical lines of three rights make a left that

Two rights will reverse everything.

since mirroring a dialog does reverse the layout. Now that is clever. It even makes some linguistic sense.

I had a very good reason for not saying it though.

I didn't think of it at the time.

Anyway, there is another fun trick like that, one that regular reader Mihai mentioned in a comment to that Just when you think you know a function... blog:

I cannot say this is really "common knowledge". I was unable to find it documented anywhere. The only thing related is adding 2 RLM in the FileDescription of the version info, which causes the full application to be mirrored. This is documented in Developing International Software, 2nd Ed."

Now Mihai actually had it wrong -- they actually want to LRM characters -- U+200e (LEFT-TO-RIGHT MARKER) -- in the FileDescription string of the version info of the binary.

But luckily the book got it right. :-)

Now I could get all clever and note that

While two wrongs don't make a right, two lefts often can.

In fact I just did. :-)

I actually like the one in the title better, technically. And from a linguistic standpoint the fact that for most people it would require three lefts to make a right causes this whole area to be pragmatically interesting in a very language-geeky way.

But the interesting question here is why did they do it this way!

I mean, doesn't it look like a bug, some kind of typo in the code from years ago that we can't change now but maybe we ought to do something since it seems wrong?

Two RLMs to make a MessageBox RTL, that makes sense.

But two LRMs to make a window RTL, that just seems wrong.

Luckily my colleague, co-worker, and teammate Mohamed is an ace in the Window Manager code and he knew why they did it this way, so when I asked him about the feature, he immediately volunteered:

It is just kind of a signature that we need to call SetProcessDefaultLayout( LAYOUT_RTL ).

We did not want to insert RLMs in front of Latin text, that is all. So we needed something that will not make any layout or shaping effect on Latin text. At the end it is a hack to make ease the localization work.

Now this is a good explanation.

The kind that takes what appears "silly" at first glance and makes some sense of it.

HOWEVER.... :-)

Anyone want to try to spot the flaw in the logic, though?

From this maybe comes the way to showcase an actual longstanding bug, and perhaps the way it should have been done, instead.

I know that most of my regulars aren't even looking since I didn't really tel anyone I was back blogging, but are there any takers? :-)


The Unicode characters were released from their original contracts when SiaO went an hiatus; only time will tell if the Characters Union (AFL-CIO) is willing to negotiate new contracts for the characters it represents...
comments not archived

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

referenced by

2010/09/20 If you are Persian, you may not always want to follow your Parent

go to newer or older post, or back to index or month or day