title: textarea auto-detection of RTL characters
body: <p>I have a textarea in which the user can enter text in English or in Arabic,
  so i need an auto-detection of characters typed, if it detects a charCodeAt() > 255 , it automatically switch the direction to RTL using jquery ..</p>
  
  <p>but the code is not wroking !</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> function isUnicode(str) {
      var letters = [];
      for (var i = 0; i &lt;= str.length; i++) {
          if (window.CP.shouldStopExecution(1)) {
              break;
          }
          letters[i] = str.substring(i - 1, i);
          if (letters[i].charCodeAt() &gt; 255) {
              return true;
          }
      }
      window.CP.exitedLoop(1);
      return false;
  }
  var dir = $('#newstatustxt');
  dir.keyup(function (e) {
      if (isUnicode(dir.val())) {
          $(this).css('direction', 'rtl');
    $(this).css('font-family', 'lucida grande,tahoma,verdana,arial,sans-serif');
      } else {
          $(this).css('direction', 'ltr');
      }
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="field"&gt;
      &lt;textarea id="newstatustxt" rows="5"&gt;&lt;/textarea&gt;
    &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>thank you in advance :)</p>