Quantcast
Channel: The Old New Thing
Viewing all articles
Browse latest Browse all 3085

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

$
0
0

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.


Viewing all articles
Browse latest Browse all 3085

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>