Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4054

Re: How to concatenate unicode strings ???

From Terry Reedy <tjreedy@udel.edu>
Subject Re: How to concatenate unicode strings ???
Date 2011-04-26 12:41 -0400
References <BANLkTikc5=6JLiWa447FuXm5riO=Hqdtnw@mail.gmail.com> <BANLkTinPn0A_kW9-SS7V5YoaVri1i8P5vw@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.848.1303836119.9059.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar


Thread

Re: How to concatenate unicode strings ??? Terry Reedy <tjreedy@udel.edu> - 2011-04-26 12:41 -0400

csiph-web