<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JavaScript Archives - The Code Developer</title>
	<atom:link href="https://www.thecodedeveloper.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.thecodedeveloper.com/category/javascript/</link>
	<description>The Code Developer is a Programming Blog.</description>
	<lastBuildDate>Thu, 09 Aug 2018 05:33:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>Count word contain UTF 8 character in javascript</title>
		<link>https://www.thecodedeveloper.com/count-word-contain-utf-8-character-in-javascript/</link>
					<comments>https://www.thecodedeveloper.com/count-word-contain-utf-8-character-in-javascript/#respond</comments>
		
		<dc:creator><![CDATA[Vikas Kumar]]></dc:creator>
		<pubDate>Fri, 20 Mar 2015 13:25:26 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">http://www.thecodedeveloper.com/?p=184</guid>

					<description><![CDATA[<div style="margin-bottom:20px;"><img width="929" height="448" src="https://www.thecodedeveloper.com/wp-content/uploads/2015/03/count-word-contain-utf-8-character.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Count Word Contain UTF 8 Character" decoding="async" fetchpriority="high" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2015/03/count-word-contain-utf-8-character.png 929w, https://www.thecodedeveloper.com/wp-content/uploads/2015/03/count-word-contain-utf-8-character-442x213.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2015/03/count-word-contain-utf-8-character-768x370.png 768w" sizes="(max-width: 929px) 100vw, 929px" /></div>
<p>Sometimes we need word counting so it easy for those language take space like Hindi, English etc. But having problem for those language don’t take space like Chinese, Japanese. So i have write JavaScript function count_word for count word contain UTF 8 character. Call JavaScript function count_word HTML Code Contains simple HTML code. Live Demo</p>
<p>The post <a href="https://www.thecodedeveloper.com/count-word-contain-utf-8-character-in-javascript/">Count word contain UTF 8 character in javascript</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div style="margin-bottom:20px;"><img width="929" height="448" src="https://www.thecodedeveloper.com/wp-content/uploads/2015/03/count-word-contain-utf-8-character.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Count Word Contain UTF 8 Character" decoding="async" srcset="https://www.thecodedeveloper.com/wp-content/uploads/2015/03/count-word-contain-utf-8-character.png 929w, https://www.thecodedeveloper.com/wp-content/uploads/2015/03/count-word-contain-utf-8-character-442x213.png 442w, https://www.thecodedeveloper.com/wp-content/uploads/2015/03/count-word-contain-utf-8-character-768x370.png 768w" sizes="(max-width: 929px) 100vw, 929px" /></div><p>Sometimes we need word counting so it easy for those language take space like Hindi, English etc. But having problem for those language don’t take space like Chinese, Japanese. So i have write JavaScript function <strong>count_word</strong> for <strong>count word contain UTF 8 character</strong>.</p>
<pre class="brush: php; title: ; notranslate">&lt;script type=&quot;text/javascript&quot;&gt;
function count_word(string)
{
    r1 = new RegExp('&#x5B;\u3000-\u4DFF]','g');
    r2 = new RegExp('&#x5B;\u4E00-\u9FFF]','g');
    r3 = new RegExp('&#x5B;\u0E00-\u0E7F]','g');
    string = string.replace(r1,' {PNK} ');
    string = string.replace(r2,' {CJK} ');
    string = string.replace(r3,' {THI} ');
    //string = string.replace(/(&lt;(&#x5B;^&gt;]+)&gt;)/ig,”&quot;) ;
    string = string.replace(/(\(|\)|\*|\||\+|\”|\’|_|;|:|,|\.|\?)/ig,&quot; &quot;) ;
    string = string.replace(/\s+/ig,&quot; &quot;);
    //string = string.replace(/_+/ig,&quot; &quot;);
    var a = string.split(/&#x5B;\s+|\\|\/]/g);
    var count = 0;
    var pnkCounter = 0;
    var thiCounter = 0;
    for (var i=0;i&lt;a.length;i++){
        if (a&#x5B;i]=='{PNK}'){
              pnkCounter++;
        }else if(a&#x5B;i]=='{THI}'){
              thiCounter++;
        }else if (a&#x5B;i].length&gt;0){
              count++;
        }
    }
    count += Math.ceil(pnkCounter/3) + Math.ceil(thiCounter/4);
    return count;
}
&lt;/script&gt;</pre>
<p>Call JavaScript function <strong>count_word</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
	$(document).ready(function(){
		$('textarea').bind(&quot;change keyup input&quot;,function() {
		   var countwords = count_word($(this).val());
		   $(&quot;.count&quot;).text(countwords);
		});
	}); 
&lt;/script&gt;
</pre>
<p>HTML Code<br />
Contains simple HTML code.</p>
<pre class="brush: php; title: ; notranslate">
&lt;div class=&quot;container&quot;&gt;
  &lt;label for = &quot;name&quot;&gt;Count Word&lt;/label&gt;
  &lt;textarea class = &quot;form-control&quot; rows = &quot;3&quot;&gt;&lt;/textarea&gt;
  &lt;p&gt;Total word Count: &lt;span class=&quot;count&quot;&gt;0&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
</pre>
<h2><a href="https://www.thecodedeveloper.com/demo/count-word-contain-utf-8-character-in-javascript/" rel="noopener" target="_blank">Live Demo</a></h2>
<p>The post <a href="https://www.thecodedeveloper.com/count-word-contain-utf-8-character-in-javascript/">Count word contain UTF 8 character in javascript</a> appeared first on <a href="https://www.thecodedeveloper.com">The Code Developer</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.thecodedeveloper.com/count-word-contain-utf-8-character-in-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
