And what about if after the string is concat I want it to pass is to the command line to do anything else, for instance:<br>one_command = cadena.decode('utf-8') + cadena1.decode('utf-8')<br>commands.getoutput(one_comand)<br>
<br>But I receive this error:<br>Traceback (most recent call last):<br> File "<console>", line 1, in <module><br> File "/usr/lib/python2.6/commands.py", line 46, in getoutput<br> return getstatusoutput(cmd)[1]<br>
File "/usr/lib/python2.6/commands.py", line 55, in getstatusoutput<br> pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')<br>UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 31: ordinal not in range(128)<br>
<br>How could I solve that ???<br>Regards<br>Ariel<br><br><div class="gmail_quote">On Tue, Apr 26, 2011 at 6:07 PM, Chris Rebert <span dir="ltr"><<a href="mailto:clp2@rebertia.com">clp2@rebertia.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">On Tue, Apr 26, 2011 at 8:58 AM, Ariel <<a href="mailto:isaacrc82@gmail.com">isaacrc82@gmail.com</a>> wrote:<br>
> Hi everybody, how could I concatenate unicode strings ???<br>
> What I want to do is this:<br>
><br>
> unicode('this an example language ') + unicode('espaņol')<br>
><br>
> but I get an:<br>
> Traceback (most recent call last):<br>
> File "<console>", line 1, in <module><br>
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 11:<br>
> ordinal not in range(128)<br>
><br>
> How could I concatenate unicode strings ???<br>
<br>
</div></div>That error is from the 2nd call to unicode(), not from the<br>
concatenation itself. Use proper Unicode string literals:<br>
<br>
u'this an example language ' + u'espaņol'<br>
<br>
You'll probably also need to add the appropriate source file encoding<br>
declaration; see <a href="http://www.python.org/dev/peps/pep-0263/" target="_blank">http://www.python.org/dev/peps/pep-0263/</a><br>
<br>
Cheers,<br>
Chris<br>
<font color="#888888">--<br>
<a href="http://rebertia.com" target="_blank">http://rebertia.com</a><br>
</font></blockquote></div><br>