<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Georgi.Budinov.com » Javascript</title>
	
	<link>http://georgi.budinov.com</link>
	<description>The sacred mission of a Web Developer - Get the job done!</description>
	<lastBuildDate>Wed, 02 Nov 2011 13:55:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/GeorgibudinovcomJavascript" /><feedburner:info uri="georgibudinovcomjavascript" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>GeorgibudinovcomJavascript</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>YouTube’s policy for inappropriate content and the embed function</title>
		<link>http://feedproxy.google.com/~r/GeorgibudinovcomJavascript/~3/0Qpj0FhRFd8/</link>
		<comments>http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 13:05:22 +0000</pubDate>
		<dc:creator>Georgi Budinov</dc:creator>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[inappropriate]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://georgi.budinov.com/?p=849</guid>
		<description><![CDATA[Recently I noticed something in the way YouTube manages the videos flagged as inappropriate by some users. You know such videos you want to watch but you must be logged in. This way you accept and confirm you are older than 18 years. On my facebook profile I had a post with such a video [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I noticed something in the way YouTube manages the videos flagged as inappropriate by some users. You know such videos you want to watch but you must be logged in. This way you accept and confirm you are older than 18 years. On my facebook profile I had a post with such a video &#8211; it is embed of the video as you know. And guess what &#8211; everyone can play it. It doesn&#8217;t matter it you are logged in or not. Here is the example:<span id="more-849"></span></p>
<p>The YouTube video &#8211; <a rel="nofollow" href="http://www.youtube.com/watch?v=bJvIWGMe61E" target="_blank">http://www.youtube.com/watch?v=bJvIWGMe61E</a></p>
<p>Try this html code for the embed:</p>
<pre class="brush: xml;">
&lt;object width=&quot;480&quot; height=&quot;385&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/bJvIWGMe61E?fs=1&amp;amp;hl=en_US&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/bJvIWGMe61E?fs=1&amp;amp;hl=en_US&quot; type=&quot;application/x-shockwave-flash&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot; width=&quot;480&quot; height=&quot;385&quot;&gt;&lt;/embed&gt;&lt;/object&gt;
</pre>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/bJvIWGMe61E?fs=1&amp;hl=en_US" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/bJvIWGMe61E?fs=1&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>And what I am thinking is : Is this a bug or feature ?</p>
<div class="social_bookmark"><script type="text/javascript"><!--
google_ad_client = "pub-1171831089941131";
google_ad_slot = "5499515740";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</div><!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><em>Bookmark It</em><br /><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/&amp;title=YouTube%26%238217%3Bs+policy+for+inappropriate+content+and+the+embed+function" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Del.icio.us"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Del.icio.us" alt="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Del.icio.us" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/&amp;title=YouTube%26%238217%3Bs+policy+for+inappropriate+content+and+the+embed+function" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in digg"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in digg" alt="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in digg" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Technorati"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Technorati" alt="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Technorati" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/&amp;t=YouTube%26%238217%3Bs+policy+for+inappropriate+content+and+the+embed+function" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Yahoo My Web"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Yahoo My Web" alt="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Yahoo My Web" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/&amp;title=YouTube%26%238217%3Bs+policy+for+inappropriate+content+and+the+embed+function" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Google Bookmarks"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Google Bookmarks" alt="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Google Bookmarks" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="https://favorites.live.com/quickadd.aspx?url=http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/&amp;title=YouTube%26%238217%3Bs+policy+for+inappropriate+content+and+the+embed+function" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Live-MSN"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/live.png" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Live-MSN" alt="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Live-MSN" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/share.php?u=http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/&amp;t=YouTube%26%238217%3Bs+policy+for+inappropriate+content+and+the+embed+function" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in FaceBook"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in FaceBook" alt="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in FaceBook" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.myspace.com/Modules/PostTo/Pages/?t=YouTube%26%238217%3Bs+policy+for+inappropriate+content+and+the+embed+function&amp;c=http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in MySpace"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/myspace.png" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in MySpace" alt="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in MySpace" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home?status=http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Twitter"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/twitter.png" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Twitter" alt="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Twitter" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://friendfeed.com/share/bookmarklet/frame#title=YouTube%26%238217%3Bs+policy+for+inappropriate+content+and+the+embed+function&amp;url=http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in FriendFeed"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/friendfeed.png" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in FriendFeed" alt="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in FriendFeed" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/reader/link?url=http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/&amp;title=YouTube%26%238217%3Bs+policy+for+inappropriate+content+and+the+embed+function&amp;srcURL=http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Google Buzz"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/googlebuzz.png" title="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Google Buzz" alt="Bookmark 'YouTube&#8217;s policy for inappropriate content and the embed function' in Google Buzz" /></a></div>
<!-- Social Bookmarking Reloaded END --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=0Qpj0FhRFd8:9QWhuKAmk8U:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=0Qpj0FhRFd8:9QWhuKAmk8U:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?i=0Qpj0FhRFd8:9QWhuKAmk8U:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=0Qpj0FhRFd8:9QWhuKAmk8U:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?i=0Qpj0FhRFd8:9QWhuKAmk8U:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=0Qpj0FhRFd8:9QWhuKAmk8U:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=0Qpj0FhRFd8:9QWhuKAmk8U:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?i=0Qpj0FhRFd8:9QWhuKAmk8U:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=0Qpj0FhRFd8:9QWhuKAmk8U:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=0Qpj0FhRFd8:9QWhuKAmk8U:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/GeorgibudinovcomJavascript/~4/0Qpj0FhRFd8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://georgi.budinov.com/2011/01/youtubes-policy-for-inappropriate-content-and-embed/</feedburner:origLink></item>
		<item>
		<title>Non-latin characters in the url and ajax problems</title>
		<link>http://feedproxy.google.com/~r/GeorgibudinovcomJavascript/~3/sZSbdUzVc5U/</link>
		<comments>http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 08:08:42 +0000</pubDate>
		<dc:creator>Georgi Budinov</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[encodeURIComponent]]></category>
		<category><![CDATA[javascript function]]></category>
		<category><![CDATA[urlencode]]></category>

		<guid isPermaLink="false">http://georgi.budinov.com/?p=796</guid>
		<description><![CDATA[These troubles have some history for me. In a month a go I experienced problems with calling ajax scripts with url holding utf8 characters &#8211; bulgarian alphabet for example. So I wrote a javascript function which actually was a bit messy that could handle the problem using encodeURIComponent. Afterwards I found that I simply could [...]]]></description>
			<content:encoded><![CDATA[<p>These troubles have some history for me. In a month a go I experienced problems with calling ajax scripts with url holding utf8 characters &#8211; bulgarian alphabet for example. So I wrote a javascript function which <span id="more-796"></span>actually was a bit messy that could handle the problem using encodeURIComponent. Afterwards I found that I simply could use urlencode in php which was a better choice according to me at that time. It looked far more clear to me, so I rewrote the functionality. Guess what &#8211; IE 6 problems. No matter that in the output of the javascript function encodeURIComponent and the php function urlencode seemed to be the same! So I had to revert back the functionality and thought to improve my javascript function and will just share that to you as it seems to be a very generic solution that will work with any url &#8230; Here it goes:</p>
<pre class="brush: php;">
function encodeCyrillicURIComponent(str)
{
	str = str.replace(
		new RegExp( &quot;[^a-zA-Z\/-:_]&quot;, &quot;g&quot; ),
		function($0)
		{
			return encodeURIComponent($0);
		}
	);

	return str;
}
</pre>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><em>Bookmark It</em><br /><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/&amp;title=Non-latin+characters+in+the+url+and+ajax+problems" title="Bookmark 'Non-latin characters in the url and ajax problems' in Del.icio.us"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Bookmark 'Non-latin characters in the url and ajax problems' in Del.icio.us" alt="Bookmark 'Non-latin characters in the url and ajax problems' in Del.icio.us" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/&amp;title=Non-latin+characters+in+the+url+and+ajax+problems" title="Bookmark 'Non-latin characters in the url and ajax problems' in digg"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Bookmark 'Non-latin characters in the url and ajax problems' in digg" alt="Bookmark 'Non-latin characters in the url and ajax problems' in digg" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/" title="Bookmark 'Non-latin characters in the url and ajax problems' in Technorati"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Bookmark 'Non-latin characters in the url and ajax problems' in Technorati" alt="Bookmark 'Non-latin characters in the url and ajax problems' in Technorati" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/&amp;t=Non-latin+characters+in+the+url+and+ajax+problems" title="Bookmark 'Non-latin characters in the url and ajax problems' in Yahoo My Web"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Bookmark 'Non-latin characters in the url and ajax problems' in Yahoo My Web" alt="Bookmark 'Non-latin characters in the url and ajax problems' in Yahoo My Web" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/&amp;title=Non-latin+characters+in+the+url+and+ajax+problems" title="Bookmark 'Non-latin characters in the url and ajax problems' in Google Bookmarks"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Bookmark 'Non-latin characters in the url and ajax problems' in Google Bookmarks" alt="Bookmark 'Non-latin characters in the url and ajax problems' in Google Bookmarks" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="https://favorites.live.com/quickadd.aspx?url=http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/&amp;title=Non-latin+characters+in+the+url+and+ajax+problems" title="Bookmark 'Non-latin characters in the url and ajax problems' in Live-MSN"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/live.png" title="Bookmark 'Non-latin characters in the url and ajax problems' in Live-MSN" alt="Bookmark 'Non-latin characters in the url and ajax problems' in Live-MSN" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/share.php?u=http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/&amp;t=Non-latin+characters+in+the+url+and+ajax+problems" title="Bookmark 'Non-latin characters in the url and ajax problems' in FaceBook"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Bookmark 'Non-latin characters in the url and ajax problems' in FaceBook" alt="Bookmark 'Non-latin characters in the url and ajax problems' in FaceBook" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.myspace.com/Modules/PostTo/Pages/?t=Non-latin+characters+in+the+url+and+ajax+problems&amp;c=http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/" title="Bookmark 'Non-latin characters in the url and ajax problems' in MySpace"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/myspace.png" title="Bookmark 'Non-latin characters in the url and ajax problems' in MySpace" alt="Bookmark 'Non-latin characters in the url and ajax problems' in MySpace" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home?status=http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/" title="Bookmark 'Non-latin characters in the url and ajax problems' in Twitter"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/twitter.png" title="Bookmark 'Non-latin characters in the url and ajax problems' in Twitter" alt="Bookmark 'Non-latin characters in the url and ajax problems' in Twitter" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://friendfeed.com/share/bookmarklet/frame#title=Non-latin+characters+in+the+url+and+ajax+problems&amp;url=http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/" title="Bookmark 'Non-latin characters in the url and ajax problems' in FriendFeed"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/friendfeed.png" title="Bookmark 'Non-latin characters in the url and ajax problems' in FriendFeed" alt="Bookmark 'Non-latin characters in the url and ajax problems' in FriendFeed" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/reader/link?url=http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/&amp;title=Non-latin+characters+in+the+url+and+ajax+problems&amp;srcURL=http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/" title="Bookmark 'Non-latin characters in the url and ajax problems' in Google Buzz"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/googlebuzz.png" title="Bookmark 'Non-latin characters in the url and ajax problems' in Google Buzz" alt="Bookmark 'Non-latin characters in the url and ajax problems' in Google Buzz" /></a></div>
<!-- Social Bookmarking Reloaded END --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=sZSbdUzVc5U:eSZBkXZ1qfA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=sZSbdUzVc5U:eSZBkXZ1qfA:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?i=sZSbdUzVc5U:eSZBkXZ1qfA:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=sZSbdUzVc5U:eSZBkXZ1qfA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?i=sZSbdUzVc5U:eSZBkXZ1qfA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=sZSbdUzVc5U:eSZBkXZ1qfA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=sZSbdUzVc5U:eSZBkXZ1qfA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?i=sZSbdUzVc5U:eSZBkXZ1qfA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=sZSbdUzVc5U:eSZBkXZ1qfA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=sZSbdUzVc5U:eSZBkXZ1qfA:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/GeorgibudinovcomJavascript/~4/sZSbdUzVc5U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://georgi.budinov.com/2010/09/non-latin-characters-in-the-url-and-ajax-problems/</feedburner:origLink></item>
		<item>
		<title>Managing fiscal printer from Datecs by browser</title>
		<link>http://feedproxy.google.com/~r/GeorgibudinovcomJavascript/~3/nu1kMHrOgAc/</link>
		<comments>http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 11:39:03 +0000</pubDate>
		<dc:creator>Georgi Budinov</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[fiscal printer]]></category>

		<guid isPermaLink="false">http://georgi.budinov.com/?p=469</guid>
		<description><![CDATA[I would like to share my experience wth a task I had to do for a project at work. The project is a web application billing software. So it needed to be able to print fiscal notes, bons or whatever. There were several ways of dealing with this stuff &#8211; creating a XPCOMM extension for [...]]]></description>
			<content:encoded><![CDATA[<p>I would like to share my experience wth a task I had to do for a project at work. The project is a web application billing software. So it needed to be able to print fiscal notes, bons or whatever. There were several ways of dealing with this stuff &#8211; creating a XPCOMM extension for FireFox, using activeX control (supporting just IE) and the java applet way. I examined <span id="more-469"></span><br />
the first two approaches and it seemed that they are not supporting all the browsers and environments. Datecs FP 550-05 is the fiscal printer I have to test which has a communication protocol and comes with a ready to use dll file. This supposes the use of activeX &#8211; I have no experience with that, no real C experience and it turned out the hardest for me. I skipped this.</p>
<p>Developping XPCOMM extension for FireFox is an interesting stuff to dig in but I had no time for that. I skipped this, too.</p>
<p>The way I went on this was java. I found a very usefull ready to use applet here &#8211; <a rel="nofollow" href="http://www.walking-productions.com/jsserial/new/JSSerial.html">JavaScript Serial</a>. There is good explanation on the site but I am a noobie on java. Actually I hate this stuff. I have never liked programming in java. So in addition to the guidelines on the site I would say something more:</p>
<ul>
<li>after initializing the applet use setTimeout for about a second before opening the port</li>
<li>program you peice of software so that your are sure that the port will be closed. If not it cannot be opened afterwards. You have to close the browser.</li>
</ul>
<p>The rest is just implementing the protocol of the device that you have to support. For the FP 550 the protocol was not very clear about packaging the messages. There was a tool to send custom commands coming together with the printer. So I started searching for software the can spy com ports. There was nothing handy but the Advanced Serial Data Logger. It is even free for a trial period which is ok for me <img src='http://georgi.budinov.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  . So I got it started to decode the messages that were being sent from the custom software of the printer. This way I could get more insight on the protocol that was unclear to me and I got the job done.</p>
<p>I want to note just one critical part. I am writing bytes to the port. So I had problems with the cyrillic characters. The page is utf-8 encoded so I had a function that generates the needed bytes to write on the printer like this:</p>
<pre class="brush: plain;">
function stringToBytes ( str )
{
  var ch, st, re = [];
  for (var i = 0; i &lt; str.length; i++ )
  {
    ch = str.charCodeAt(i);  // get char
    if(ch &gt;= 1040 &amp;&amp; ch &lt;= 1103)
    {
        re = re.concat( [ch - 912] );
    }
    else
    {
        st = [];                 // set up &quot;stack&quot;
        do {
        st.push( ch &amp; 0xFF );  // push byte to stack
        ch = ch &gt;&gt; 8;          // shift value down by 1 byte
    }
    while ( ch );
    // add stack contents to result
    // done because chars have &quot;wrong&quot; endianness
    re = re.concat( st.reverse() );
  }
 }
 // return an array of bytes

 return re;
}
</pre>
<p>I found this function on stackoverflow but I had to modify it because of the non-latin characters problem. The movement of 912 is when you use utf8. The encoding is different then you have to move the character bits by different ammount.</p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><em>Bookmark It</em><br /><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/&amp;title=Managing+fiscal+printer+from+Datecs+by+browser" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Del.icio.us"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Del.icio.us" alt="Bookmark 'Managing fiscal printer from Datecs by browser' in Del.icio.us" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/&amp;title=Managing+fiscal+printer+from+Datecs+by+browser" title="Bookmark 'Managing fiscal printer from Datecs by browser' in digg"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Bookmark 'Managing fiscal printer from Datecs by browser' in digg" alt="Bookmark 'Managing fiscal printer from Datecs by browser' in digg" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Technorati"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Technorati" alt="Bookmark 'Managing fiscal printer from Datecs by browser' in Technorati" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/&amp;t=Managing+fiscal+printer+from+Datecs+by+browser" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Yahoo My Web"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Yahoo My Web" alt="Bookmark 'Managing fiscal printer from Datecs by browser' in Yahoo My Web" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/&amp;title=Managing+fiscal+printer+from+Datecs+by+browser" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Google Bookmarks"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Google Bookmarks" alt="Bookmark 'Managing fiscal printer from Datecs by browser' in Google Bookmarks" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="https://favorites.live.com/quickadd.aspx?url=http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/&amp;title=Managing+fiscal+printer+from+Datecs+by+browser" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Live-MSN"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/live.png" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Live-MSN" alt="Bookmark 'Managing fiscal printer from Datecs by browser' in Live-MSN" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/share.php?u=http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/&amp;t=Managing+fiscal+printer+from+Datecs+by+browser" title="Bookmark 'Managing fiscal printer from Datecs by browser' in FaceBook"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Bookmark 'Managing fiscal printer from Datecs by browser' in FaceBook" alt="Bookmark 'Managing fiscal printer from Datecs by browser' in FaceBook" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.myspace.com/Modules/PostTo/Pages/?t=Managing+fiscal+printer+from+Datecs+by+browser&amp;c=http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/" title="Bookmark 'Managing fiscal printer from Datecs by browser' in MySpace"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/myspace.png" title="Bookmark 'Managing fiscal printer from Datecs by browser' in MySpace" alt="Bookmark 'Managing fiscal printer from Datecs by browser' in MySpace" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home?status=http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Twitter"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/twitter.png" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Twitter" alt="Bookmark 'Managing fiscal printer from Datecs by browser' in Twitter" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://friendfeed.com/share/bookmarklet/frame#title=Managing+fiscal+printer+from+Datecs+by+browser&amp;url=http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/" title="Bookmark 'Managing fiscal printer from Datecs by browser' in FriendFeed"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/friendfeed.png" title="Bookmark 'Managing fiscal printer from Datecs by browser' in FriendFeed" alt="Bookmark 'Managing fiscal printer from Datecs by browser' in FriendFeed" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/reader/link?url=http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/&amp;title=Managing+fiscal+printer+from+Datecs+by+browser&amp;srcURL=http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Google Buzz"><img src="http://georgi.budinov.com/wp-content/plugins/social-bookmarking-reloaded/googlebuzz.png" title="Bookmark 'Managing fiscal printer from Datecs by browser' in Google Buzz" alt="Bookmark 'Managing fiscal printer from Datecs by browser' in Google Buzz" /></a></div>
<!-- Social Bookmarking Reloaded END --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=nu1kMHrOgAc:BUSryqjC7R8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=nu1kMHrOgAc:BUSryqjC7R8:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?i=nu1kMHrOgAc:BUSryqjC7R8:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=nu1kMHrOgAc:BUSryqjC7R8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?i=nu1kMHrOgAc:BUSryqjC7R8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=nu1kMHrOgAc:BUSryqjC7R8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=nu1kMHrOgAc:BUSryqjC7R8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?i=nu1kMHrOgAc:BUSryqjC7R8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=nu1kMHrOgAc:BUSryqjC7R8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?a=nu1kMHrOgAc:BUSryqjC7R8:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/GeorgibudinovcomJavascript?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/GeorgibudinovcomJavascript/~4/nu1kMHrOgAc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://georgi.budinov.com/2010/07/managing-fiscal-printer-fom-datecs-by-browser/</feedburner:origLink></item>
	</channel>
</rss>

