Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'received:209.85.212.46': 0.03; 'received:mail-vw0-f46.google.com': 0.03; 'everybody,': 0.09; 'url:dev': 0.09; 'url:peps': 0.09; 'this:': 0.11; 'am,': 0.14; 'wrote:': 0.14; 'an:': 0.16; 'codec': 0.16; 'declaration;': 0.16; 'literals:': 0.16; 'ordinal': 0.16; 'subject: ???': 0.16; 'subject:unicode': 0.16; 'url:pep-0263': 0.16; 'traceback': 0.16; '(most': 0.16; 'tue,': 0.20; 'cc:2**0': 0.20; 'cheers,': 0.20; 'language': 0.20; 'appropriate': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:addr:python-list': 0.22; 'itself.': 0.22; 'last):': 0.23; 'example': 0.24; 'received:209.85.212': 0.25; 'byte': 0.25; 'chris': 0.27; 'message-id:@mail.gmail.com': 0.28; 'string': 0.29; 'error': 0.29; 'unicode': 0.29; 'probably': 0.30; 'cc:addr:python.org': 0.31; "can't": 0.31; 'source': 0.32; 'file': 0.35; '"",': 0.35; '???': 0.35; 'received:209.85': 0.37; 'url:python': 0.37; 'apr': 0.38; 'strings': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'url:org': 0.38; 'could': 0.39; 'received:209': 0.39; 'how': 0.39; 'add': 0.39; 'header:Received:5': 0.40; '8bit%:11': 0.60; '2011': 0.62; '26,': 0.68; 'concatenate': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=gLVBRsv667N7StcuBqEicBpNtxEYyXqDsrurqxWZV0g=; b=Uds/8X2npVm2apvsFb+h1eI0ba14uUwO3CDRaCX03N4JTuGj+AL68CwEyGo/Nn+aOL r5rT54j5WqXJe3ym7uCiyDXPF6QjPcEMcqOU2cEK70z9ZDi4b4iPcXgy9r8sQya6K6QQ cn7LaEpNNBZDp+NH+Bz1g8H6k3QqBQb0PiPvA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=RrKPxTz4sk3vfwBkHXgH/y1EE+554tUEKXuaqMti0jHOUsaGNiysBD1xgLC6PXe6Pi 0zgg61+jQAHZuEJs91rNH658kHoLFe8Q+3gkQUA1WyKXr7fNn06C0qfPdbzK5bI+jjc9 W8sN6Yoqw733MS6c9/+UoBiEN/+C+pNPERz90= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: References: Date: Tue, 26 Apr 2011 09:07:16 -0700 X-Google-Sender-Auth: EPDlZJ4oNKThmtakqhDUT1jIXlg Subject: Re: How to concatenate unicode strings ??? From: Chris Rebert To: Ariel Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303834039 news.xs4all.nl 81483 [::ffff:82.94.164.166]:59287 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4049 On Tue, Apr 26, 2011 at 8:58 AM, Ariel wrote: > Hi everybody, how could I concatenate unicode strings ??? > What I want to do is this: > > unicode('this an example language ') + unicode('espa=C3=B1ol') > > but I get an: > Traceback (most recent call last): > =C2=A0 File "", line 1, in > 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=C3=B1ol' 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