with commands.getoutput(one_comand.encode('utf-8')) it works !!! On Tue, Apr 26, 2011 at 6:22 PM, Ariel <isaacr...@gmail.com> wrote:
> 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: > one_command = cadena.decode('utf-8') + cadena1.decode('utf-8') > commands.getoutput(one_comand) > > But I receive this error: > > Traceback (most recent call last): > File "<console>", line 1, in <module> > File "/usr/lib/python2.6/commands.py", line 46, in getoutput > return getstatusoutput(cmd)[1] > File "/usr/lib/python2.6/commands.py", line 55, in getstatusoutput > pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r') > UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in > position 31: ordinal not in range(128) > > How could I solve that ??? > Regards > Ariel > > > On Tue, Apr 26, 2011 at 6:07 PM, Chris Rebert <c...@rebertia.com> wrote: > >> On Tue, Apr 26, 2011 at 8:58 AM, Ariel <isaacr...@gmail.com> wrote: >> > Hi everybody, how could I concatenate unicode strings ??? >> > What I want to do is this: >> > >> > unicode('this an example language ') + unicode('español') >> > >> > but I get an: >> > Traceback (most recent call last): >> > File "<console>", line 1, in <module> >> > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 11: >> > ordinal not in range(128) >> > >> > How could I concatenate unicode strings ??? >> >> That error is from the 2nd call to unicode(), not from the >> concatenation itself. Use proper Unicode string literals: >> >> u'this an example language ' + u'español' >> >> You'll probably also need to add the appropriate source file encoding >> declaration; see http://www.python.org/dev/peps/pep-0263/ >> >> Cheers, >> Chris >> -- >> http://rebertia.com >> > >
-- http://mail.python.org/mailman/listinfo/python-list