Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8400607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:36:00+00:00 2026-06-09T21:36:00+00:00

How can I programmatically check if the browser treats some character as RTL in

  • 0

How can I programmatically check if the browser treats some character as RTL in JavaScript?

Maybe creating some transparent DIV and looking at where text is placed?

A bit of context. Unicode 5.2 added Avestan alphabet support. So, if the browser has Unicode 5.2 support, it treats characters like U+10B00 as RTL (currently only Firefox does). Otherwise, it treats these characters as LTR, because this is the default.

How do I programmatically check this? I’m writing an Avestan input script and I want to override the bidi direction if the browser is too dumb. But, if browser does support Unicode, bidi settings shouldn’t be overriden (since this will allow mixing Avestan and Cyrillic).

I currently do this:

var ua = navigator.userAgent.toLowerCase();

if (ua.match('webkit') || ua.match('presto') || ua.match('trident')) {
    var input = document.getElementById('orig');
    if (input) {
        input.style.direction = 'rtl';
        input.style.unicodeBidi = 'bidi-override';
    }
}

But, obviously, this would render script less usable after Chrome and Opera start supporting Unicode 5.2.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:36:02+00:00Added an answer on June 9, 2026 at 9:36 pm

    Thanks for your comments, but it seems I’ve done this myself:

    function is_script_rtl(t) {
        var d, s1, s2, bodies;
    
        //If the browser doesn’t support this, it probably doesn’t support Unicode 5.2
        if (!("getBoundingClientRect" in document.documentElement))
            return false;
    
        //Set up a testing DIV
        d = document.createElement('div');
        d.style.position = 'absolute';
        d.style.visibility = 'hidden';
        d.style.width = 'auto';
        d.style.height = 'auto';
        d.style.fontSize = '10px';
        d.style.fontFamily = "'Ahuramzda'";
        d.appendChild(document.createTextNode(t));
    
        s1 = document.createElement("span");
        s1.appendChild(document.createTextNode(t));
        d.appendChild(s1);
    
        s2 = document.createElement("span");
        s2.appendChild(document.createTextNode(t));
        d.appendChild(s2);
    
        d.appendChild(document.createTextNode(t));
    
        bodies = document.getElementsByTagName('body');
        if (bodies) {
            var body, r1, r2;
    
            body = bodies[0];
            body.appendChild(d);
            var r1 = s1.getBoundingClientRect();
            var r2 = s2.getBoundingClientRect();
            body.removeChild(d);
    
            return r1.left > r2.left;
        }
    
        return false;   
    }
    

    Example of using:

    Avestan in <script>document.write(is_script_rtl('') ? "RTL" : "LTR")</script>,
    Arabic is <script>document.write(is_script_rtl('العربية') ? "RTL" : "LTR")</script>,
    English is <script>document.write(is_script_rtl('English') ? "RTL" : "LTR")</script>.
    

    It seems to work. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I programmatically check a checkbox in Coffeescript ? I know in Javascript,
How can programmatically check which version of the WMI (Windows Management Instrumentation) is installed
I can easily check IP addresses programmatically, but is there any way to set
I want to programmatically check if a site has feeds. How can I do
Does anybody know how I can programmatically check (using C#) whether my program will
Possible Duplicate: Programmatically find device support GPS or not? How can I check, is
jQuery.fn.jquery equivalent for jQuery Mobile? To programmatically check the version of jQuery one can
How can I check programmatically, how much memory my program currently has allocated ?
Is there a way how I can check programmatically which user is used when
DUPE: How to programmatically check Internet bandwidth in VC++? Can we find the bandwidth

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.