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


Groups > comp.lang.python > #4049

Re: How to concatenate unicode strings ???

References <BANLkTikc5=6JLiWa447FuXm5riO=Hqdtnw@mail.gmail.com>
Date 2011-04-26 09:07 -0700
Subject Re: How to concatenate unicode strings ???
From Chris Rebert <clp2@rebertia.com>
Newsgroups comp.lang.python
Message-ID <mailman.841.1303834038.9059.python-list@python.org> (permalink)

Show all headers | View raw


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/

Cheers,
Chris
--
http://rebertia.com

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


Thread

Re: How to concatenate unicode strings ??? Chris Rebert <clp2@rebertia.com> - 2011-04-26 09:07 -0700

csiph-web