Handling Character count for twitter post which includes URL
<p>I am allowing users to post comments from my site to directly twitter using API. I am using same character counter as twitter. I am allowing users to enter 140 character and as user starts typing in, I am reducing the character count. I am also allowing users to enter more than 140 character but he can not submit the comment if count is more than 140 characters.</p>

<p>All above functionality is working fine. The problem come in picture when user enter the any URL e.g. <a href="http://www.google.com" rel="nofollow">http://www.google.com</a> </p>

<p>If you type "the <a href="http://www.google.com" rel="nofollow">http://www.google.com</a>" in twitter the it counts it 24 character and shows 116 char remaining.</p>

<p>How could I handle this? If I allow user to type <a href="http://www.google.com" rel="nofollow">http://www.google.com</a> with 119 more characters then I can not post it to twiiter. It is returning below error message-</p>

<pre><code> REST Response Error: simplexml_load_string() [&lt;a href='function.simplexml-   load-string'&gt;function.simplexml-load-string&lt;/a&gt;]: ^
</code></pre>

<p>How twitter count the character of a URL??</p>

<p>I am using the below class for character counter - </p>

<p><a href="http://cssglobe.com/post/7161/jquery-plugin-simplest-twitterlike-dynamic-character-count-for-textareas" rel="nofollow">http://cssglobe.com/post/7161/jquery-plugin-simplest-twitterlike-dynamic-character-count-for-textareas</a> which I have cusomized as below - </p>

<pre><code> (function($) {

$.fn.charCount = function(options){

    // default configuration properties
    var defaults = {    
        allowed: 140,       
        warning: 25,
        css: 'counter',
        counterElement: 'span',
        cssWarning: 'warning',
        cssExceeded: 'exceeded',
        counterText: ''
    }; 

    var options = $.extend(defaults, options); 

    function calculate(obj){
        var count = $(obj).val().length;
        var strButton = "";
        if(count &gt;= 1){
            strButton = "1";
            $('#fcButtonsAct').show();
            $('#fcButtonsDis').hide();
        }else{
            $('#fcButtonsAct').hide();
            $('#fcButtonsDis').hide();
        }
        var myObj = $('#myCharCounter');

        var available = options.allowed - count;
        if(available &lt;= options.warning &amp;&amp; available &gt;= 0){
            $(myObj).addClass(options.cssWarning);
        } else {
            $(myObj).removeClass(options.cssWarning);
        }
        if(available &lt; 0){
            strButton = "1";
            $(myObj).addClass(options.cssExceeded);
            $('#fcButtonsAct').hide();
            $('#fcButtonsDis').show();
        } else {
            $(myObj).removeClass(options.cssExceeded);
        }

        $(myObj).html('&lt;div style="float:right;line-height:28px;"&gt;&lt;i&gt;' + available + ' &lt;/i&gt;&lt;/div&gt;');
    };

    this.each(function() {
        calculate(this);
        $(this).keyup(function(){calculate(this)});
        $(this).change(function(){calculate(this)});
    });

 };

 })(jQuery);
</code></pre>

<p>and getting done it by calling below function </p>

<pre><code>$("#txtuserstatus").charCount({
      allowed: 140,
      warning: 10,
      counterText: '',
      counterElement: 'div'
 });
</code></pre>

<p>Thanks in advance.</p>
