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 07:01 -04:00, original URI:

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 me, 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... 

parkrrrr on 9 Apr 2009 2:55 PM:

Say you're heading north up 156 Ave. NW toward the MS campus, and you turn left on Bel-Red, then left again on NE 24th St.  

There you go, two lefts made a right.

(Also, you underestimate the glacial pace with which your regular readers purge their RSS readers of stagnant blogs.)

Joe on 10 Apr 2009 9:27 AM:

No takers yet, so I'll give my guess...

It doesn't make sense to mirror the layout when using Latin text, so what difference does it make if you try? If you want to do something goofy, go right ahead.

Michael S. Kaplan on 13 Apr 2009 2:37 AM:

Hey Joe --

A hint -- remember that the text in the FileDescription may be LTR or may be RTL -- entirely independent of what the dialogs are supposed to be doing.

Euro on 15 Apr 2009 4:55 PM:

I'm not a regular reader... well -- I guess I might be since I check almost everyday. But not a localization expert by any stretch (even though I should force myself to become one since I speak and write fluently in three languages). You just write interesting stuff, even when it's 6 miles over my head.

Anyway; I'll give it a try:

If you want to have a FileDescription written in a RTL language for you RTL-localized application, you're going to be surprised.

I wonder; can you use a pair of LRMs followed by a RLM to make your FileDescription RTL?

(I thought of this before reading your hint; I hope I earn extra credit if I'm right. If I'm wrong, then it doesn't matter -- it teaches me not to speculate in an area I know almost nothing about).

Anyway -- Welcome back.

Thomas Selbitschka on 26 Apr 2010 7:07 PM:

Two wrongs don't make a right, but three lefts do....

Dahl on 19 Jan 2011 2:23 PM:

"two wrongs don't make a right" is a DMV question! All their questions are all like "Do You Not - blah, blah, blah ...?" No matter how you answer you WILL get it wrong!

uy on 3 Feb 2012 9:57 AM:


jojo on 27 Feb 2013 10:41 AM:

go kill yourself

Michael S. Kaplan on 27 Feb 2013 12:10 PM:

You first, comrade!

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