<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">
    So if you can, you could make sure to send the file as just bytes,<br>
    or if it must be a string, base64 encoded. If this is not possible<br>
    you can try the code below to obtain the bytes, not a very fast<br>
    solution, but it should work (Python 3):<br>
<br>
<br>
    MAP = {}<br>
    for i in range(256):<br>
         MAP[tmp] = eval("'\\u%04i'" % i)<br>
</div></blockquote><div class="im">
><br>
>     # Let's say 'a' is your string<br>
>     b''.join([MAP[c] for c in a])<br>
><br>
<br></div>
I don't know what you're trying to do here.<br>
<br>
1. 'tmp' is the same for every iteration of the 'for' loop.<br>
<br>
2. A Unicode escape sequence expects 4 hexadecimal digits; the 'i'<br>
format gives a decimal number.<br>
<br>
3. Using 'eval' to make a string this way is the long (and wrong) way<br>
to do it; chr(i) would have the same effect.<br>
<br>
4. The result of the eval is a string, but you're performing a join<br>
with a bytestring, hence the exception.</blockquote><div><br>Mmm, you're right. I didn't look at this carefully enough, and then made an error in copying the source code. Sorry for that ...<br><br>Here's a solution that should work (if I understand your problem correctly):<br>
your_bytes = bytes([ord(c) for c in your_string])<br><br>  Almar<br></div></div>