<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/18479" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2011-05-28T20:16:25-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/18479</id>

		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2011-05-28T20:16:25-04:00</updated>

		<published>2011-05-28T20:16:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96948#p96948</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96948#p96948"/>
		<title type="html"><![CDATA[Issues with TCL encoding on Eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96948#p96948"><![CDATA[
Also, seems your script needs food badly, it is about to die. Remember, don't shoot food. Red elf needs food badly. Red elf is dead. When does this happen you ask? Well... deprecation has already begun in the form of rate limits. On December 1st, 2011 it's put to rest entirely.<br><br>See here -&gt; <a href="http://code.google.com/apis/language/translate/overview.html" class="postlink">http://code.google.com/apis/language/tr ... rview.html</a><br><br>It's dead jim.<br><br><br>But keep in mind, that there is another way...<br>"It is important to stress that the Translate API is not the Google Translate web site, nor the Google Translate Web element."<br><br>So Incith:Google's translate function will continue to function as it always has...<br>/me smiles gleefully and feels a bit sad for chronoz at the same time..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Sat May 28, 2011 8:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[chronoz]]></name></author>
		<updated>2011-05-21T19:54:03-04:00</updated>

		<published>2011-05-21T19:54:03-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96932#p96932</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96932#p96932"/>
		<title type="html"><![CDATA[Issues with TCL encoding on Eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96932#p96932"><![CDATA[
Thanks! Removing the [encoding convertto utf-8 $translated] indeed solved the issue. I added it before recompiling eggdrop for utf-8 to see if it would solve the issue.<br><br>Recompiling eggdrop for utf-8 actually solved the issue, while adding [encoding convertto utf-8 $translated] broke it again. <br><br>Appreciate the thorough response!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11672">chronoz</a> — Sat May 21, 2011 7:54 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2011-05-20T16:54:39-04:00</updated>

		<published>2011-05-20T16:54:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96922#p96922</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96922#p96922"/>
		<title type="html"><![CDATA[Issues with TCL encoding on Eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96922#p96922"><![CDATA[
<blockquote class="uncited"><div>&lt;speechl3s&gt; !tr @fr I am a stranger  --swapo<br>&lt;sp33chy&gt; Google: (auto-&gt;fr) Romanian to French translation<br>&lt;sp33chy&gt; Je suis un Ã©tranger<br><br>&lt;speechl3s&gt; !tr @fr I am a stranger<br>&lt;sp33chy&gt;  Google: (auto-&gt;fr) Romanian to French translation<br>&lt;sp33chy&gt;  Je suis un étranger<br><br>&lt;speechl3s&gt; !tr @zh I am a stranger<br>&lt;sp33chy&gt;  Google: (auto-&gt;zh) Malay to Chinese translation<br>&lt;sp33chy&gt;  我是一个蠕虫<br><br>&lt;speechl3s&gt; !tr en@zh I am a stranger<br>&lt;sp33chy&gt; Google: (en-&gt;zh) English to Chinese translation<br>&lt;sp33chy&gt; 我是个陌生人<br><br>&lt;speechl3s&gt; !tr @ar I am a stranger<br>&lt;sp33chy&gt;  Google: (auto-&gt;ar) English to Arabic translation<br>&lt;sp33chy&gt;  أنا غريب<br><br>&lt;speechl3s&gt; !tr @fr I have prepared lots of cookies for the entire family. <br>&lt;sp33chy&gt; Google: (auto-&gt;fr) English to French translation<br>&lt;sp33chy&gt; J'ai préparé beaucoup de biscuits pour toute la famille.<br><br>&lt;speechl3s&gt; !tr @fr I have prepared lots of cookies for the entire family. --swapo<br>&lt;sp33chy&gt; Google: (auto-&gt;fr) English to French translation<br>&lt;sp33chy&gt;  J'ai prÃ©parÃ© beaucoup de biscuits pour toute la famille.<br><br>&lt;speechl3s&gt; !tr @ar The special characters are processed. <br>&lt;sp33chy&gt; Google: (auto-&gt;ar) English to Arabic translation<br>&lt;sp33chy&gt; تتم معالجة الأحرف الخاصة.<br><br>&lt;speechl3s&gt; !tr تتم معالجة الأحرف الخاصة<br>&lt;sp33chy&gt; Google: (auto-&gt;en) Arabic to English translation<br>&lt;sp33chy&gt; Special characters are processed</div></blockquote>Let me (the google magician) explain a few things. Notice my translate script works. Correctly, and at the same time I can break it, and make it work like yours does.<br><br>So let me explain what you are doing wrong....<br><br>You've patched your bot. Hopefully correctly.. Let's move on..<br><div class="codebox"><p>Code: </p><pre><code>set dturl "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&amp;q=$text" </code></pre></div>First off, the url has no google encodings within it. Why do you not use &amp;oe= and &amp;ie= to define your input and output encodings to google? Also, your format query has "q" and $text within it. Why do you then add q=$text??! O_o;;?!<br>Change that to look like it does below...<div class="codebox"><p>Code: </p><pre><code>set dturl "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&amp;ie=utf-8&amp;oe=utf-8$text"</code></pre></div>Then...<div class="codebox"><p>Code: </p><pre><code>set text [http::formatQuery q [join [lrange [split $text] 1 end]]]</code></pre></div>You http::formatQuery before you've ever configured your url encoding to utf-8.. WHY?<br>Change it to look like below...<div class="codebox"><p>Code: </p><pre><code>http::config -urlencoding {utf-8}set text [http::formatQuery q [join [lrange [split $text] 1 end]]]</code></pre></div>Finally, and this is the one likely causing your issue... <div class="codebox"><p>Code: </p><pre><code>putserv "PRIVMSG $chan :[encoding convertto utf-8 $translated]" </code></pre></div>Why are you converting encoding at all? Your bots system encoding is already utf-8 if you've properly patched your eggdrop. Doing that again will cause double conversion and mangle your characters..<br>Change this as well to look like below:<div class="codebox"><p>Code: </p><pre><code>putserv "PRIVMSG $chan :$translated"</code></pre></div> <br><br>Finally, change this line below<div class="codebox"><p>Code: </p><pre><code>package require http</code></pre></div>to this one..<div class="codebox"><p>Code: </p><pre><code>package require http 2.5</code></pre></div>url-encoding was added as an option in http version 2.5. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>Doing all that I say, making these changes. You will notice your translate script now works. No thanks required. I've found out how to make perfect utf-8 several years ago <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Fri May 20, 2011 4:54 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[chronoz]]></name></author>
		<updated>2011-05-19T16:21:38-04:00</updated>

		<published>2011-05-19T16:21:38-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96917#p96917</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96917#p96917"/>
		<title type="html"><![CDATA[Issues with TCL encoding on Eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96917#p96917"><![CDATA[
I have installed Eggdrop on a new Debian server, but it keeps having issues with processing special characters. <br><br>Eggdrop is running utf-8. I have even manually enforced TCL encoding to utf-8 in the script. And I have tried recompiling Eggdrop with instructions from <a href="http://eggwiki.org/Utf-8" class="postlink">http://eggwiki.org/Utf-8</a>.  <br><div class="codebox"><p>Code: </p><pre><code>22:00 &lt;@me&gt; !tr fr I have prepared lots of cookies for the entire family.22:00 &lt;@bot&gt; J'ai prÃÂ©parÃÂ© beaucoup de biscuits pour toute la famille.22:00 &lt;@me&gt; !tr ar The special characters are processed.22:00 &lt;@bot&gt; ÃÂªÃÂªÃE ÃEÃÂ¹ÃÂ§ÃDÃÂ¬ÃÂ© ÃÂ§ÃDÃÂ£ÃÂ­ÃÂ±ÃA ÃÂ§ÃDÃÂ®ÃÂ§ÃÂµÃÂ©.</code></pre></div>(Also see a previous Question asked, that did not get solved: <a href="http://stackoverflow.com/questions/6008280/issues-with-tcl-encoding-on-eggdrop" class="postlink">http://stackoverflow.com/questions/6008 ... on-eggdrop</a>)<br><div class="codebox"><p>Code: </p><pre><code>namespace eval gTranslator {# Factor this out into a helperproc getJson url {  set tok [http::geturl $url]  set res [json::json2dict [http::data $tok]]  http::cleanup $tok  return $res}# How to decode _decimal_ entities; WARNING: high magic factor within!proc decodeEntities str {  set str [string map {\[ {\[} \] {\]} \$ {\$} \\ \\\\} $str]  subst [regsub -all {&amp;#(\d+);} $str {[format %c \1]}]}bind pub - !tr gTranslator::translateproc translate { nick uhost handle chan text } {  package require http  package require json  set lngto [string tolower [lindex [split $text] 0]]  set text [http::formatQuery q [join [lrange [split $text] 1 end]]]  set dturl "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&amp;q=$text"  set lng [dict get [getJson $dturl] responseData language]  if { $lng == $lngto } {putserv "PRIVMSG $chan :\002Error\002 translating $lng to $lngto."return 0  }  set trurl "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&amp;langpair=$lng%7c$lngto&amp;$text"  putlog $trurl  set res [getJson $trurl]  putlog $res  #putserv "PRIVMSG $chan :Language detected: $lng"  set translated [decodeEntities [dict get $res responseData translatedText]]  putserv "PRIVMSG $chan :[encoding convertto utf-8 $translated]"}}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11672">chronoz</a> — Thu May 19, 2011 4:21 pm</p><hr />
]]></content>
	</entry>
	</feed>
