<div dir="ltr"><div>Thank you all for your help!</div>
<div> </div>
<div>i tried the buffer idea, but it gave me a &#39;buffer&#39; type and not a byteArray.</div>
<div>so i tried Michael&#39;s idea, which gave me some error. but then I found this post: <a href="http://www.smallshire.org.uk/sufficientlysmall/tag/ironpython/">http://www.smallshire.org.uk/sufficientlysmall/tag/ironpython/</a></div>

<div> </div>
<div>I fixed the code to:</div>
<div><font face="Courier New">from</font> <code class="plain">System </code><code class="keyword">import</code> <code class="plain">Array, Byte </code>
<div class="line alt2"><span class="content"><span style="MARGIN-LEFT: 0px !important" class="block"><code class="plain">a </code><code class="keyword">=</code> <code class="plain">Array[Byte](tuple(Byte(ord(c)) </code><code class="keyword">for</code> <code class="plain">c </code><code class="keyword">in</code> <font face="Courier New">image</font><code class="plain">)) </code></span></span></div>

<div class="line alt2"><span class="content"><span style="MARGIN-LEFT: 0px !important" class="block"><code class="plain"></code></span></span> </div>
<div class="line alt2"><span class="content"><span style="MARGIN-LEFT: 0px !important" class="block"><code class="plain"><span class="content"><span style="MARGIN-LEFT: 0px !important" class="block"><code class="plain"><span class="content"><span style="MARGIN-LEFT: 0px !important" class="block"><code class="plain"><span class="content"><span style="MARGIN-LEFT: 0px !important" class="block"><code class="plain"><span class="content"><span style="MARGIN-LEFT: 0px !important" class="block"><code class="plain">which seems to work :-)</code></span></span></code></span></span></code></span></span></code></span></span></code></span></span></div>

<div class="line alt2"><span class="content"><span style="MARGIN-LEFT: 0px !important" class="block"><code class="plain"><span class="content"><span style="MARGIN-LEFT: 0px !important" class="block"><code class="plain"><span class="content"><span style="MARGIN-LEFT: 0px !important" class="block"><code class="plain"><span class="content"><span style="MARGIN-LEFT: 0px !important" class="block"><code class="plain"><span class="content"><span style="MARGIN-LEFT: 0px !important" class="block"><code class="plain"></code></span></span></code></span></span></code></span></span></code></span></span></code></span></span> </div>

<div class="line alt2">Like Tony said, Thanks a lot for the info!</div>
<div class="line alt2"><font face="Courier New"></font><br><br> </div></div>
<div class="gmail_quote">On Thu, Nov 12, 2009 at 6:21 AM, Toni Alatalo <span dir="ltr">&lt;<a href="mailto:antont@kyperjokki.fi">antont@kyperjokki.fi</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Vernon Cole kirjoitti: 
<div class="im"><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Make sure what data type is really being returned by part.getpayload() .  Perhaps it is already in a suitable for when you get it?<br>
</blockquote><br></div>Before he posted to the list we actually talked about this on irc too, and it seemed that it was unicode. He was seeing type &#39;str&#39;, but it seemed that str is unicode on ironpy, so probably that&#39;s why giving it to create a byte array doesn&#39;t work.<br>

<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div class="im">s = &#39;this is a string&#39;<br>b = buffer(s)<br></div>
<div class="im">stores &quot;strings&quot; in unicode, and buffer() tries to be smart about hiding that fact, in order to act like CPython in the easy cases.  The above will work the same in either IronPython or CPython.<br>
</div></blockquote><br>Ok, AFAIK he wasn&#39;t trying buffer() yet and I also didnt&#39;t know much about it, so perhaps this is it? I&#39;m sure he&#39;ll try soon. 
<div class="im"><br><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">(IronPython seems to store them internally in UTF-8 or some similar code.)  To convert to &quot;proper&quot; 8-bit codes you must use something like:<br>
u = u&#39;unicode string&#39;<br>b = buffer(u.encode(&#39;latin-1&#39;))<br></blockquote><br></div>The string/bytes is an image from an email (using some .net lib i guess, dunno on what that getpayload() is), I wonder if something like &#39;latin-1&#39; is still the thing to use :o 
<div class="im"><br><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Python 3.x removes the problem by defining all character strings as unicode (as IronPython does now), and providing a byte() function, in which each 8 byte is treated as an integer, rather than a character. That will make things simpler in the future.<br>
</blockquote><br></div>Indeed, perhaps the main reason why am looking forward to living in that land eventually.<br><br>Thanks for info! (I and the OP work in the same overall project (<a href="http://www.realxtend.org/" target="_blank">http://www.realxtend.org/</a> open source virtual worlds / network games plat), even though I&#39;m not working on the same thing he is now (we use ironpy on the server and cpython on the client, I&#39;m mostly busy with the client side right now)<br>
<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">VC<br></blockquote><br>~Toni<br><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div class="im"><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
 <br></div></blockquote>
<div>
<div></div>
<div class="h5"><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
</div></div></blockquote></div><br></div>