How to concatenate unicode strings ???
Jean-Michel Pichavant
jeanmichel at sequans.com
Tue Apr 26 12:38:34 EDT 2011
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/
>> Cheers,
> Chris
> --
> http://rebertia.com
>an example of shebang
#!/usr/bin/python
# -*- coding: utf-8 -*-
that should allow you to write u'español' in your code.
JM
More information about the Python-list
mailing list