How do I determine programmatically whether a particular language is LTR or RTL?

Raymond Chen

Given an LCID, how does one determine whether the language lays out left-to-right or right-to-left? One suggestion was simply to hard-code the list of known right-to-left languages, and if the language isn’t on the list, then assume that it is left-to-right. This technique is clearly fragile, because Windows adds support for new languages not infrequently, and if one of those is a right-to-left language, then your table is now out of date. And besides, there are languages whose layout is neither left-to-right nor right-to-left. For example, Chinese and Japanese traditionally lay out top-to-bottom. To obtain the text layout direction programmatically, call Get­Locale­Info­Ex with LOCALE_IREADINGLAYOUT.

And just hope that nobody ever hands you a boustrophedonic language.


Discussion is closed.

Feedback usabilla icon