How to concatenate unicode strings ???

Terry Reedy tjreedy at udel.edu
Tue Apr 26 18:41:40 CEST 2011


On 4/26/2011 12:07 PM, Chris Rebert wrote:
> On Tue, Apr 26, 2011 at 8:58 AM, Ariel<isaacrc82 at 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/

Or use Python 3

-- 
Terry Jan Reedy





More information about the Python-list mailing list