Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'error:': 0.05; 'failing': 0.05; 'ascii': 0.07; 'completeness': 0.07; 'problem?': 0.07; 'properly.': 0.07; 'python': 0.09; 'anders': 0.09; 'codecs': 0.09; 'encode': 0.09; 'lost.': 0.09; 'non-ascii': 0.09; 'received:155': 0.09; 'subject:error': 0.11; '(where': 0.15; '66,': 0.16; 'codec': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'i.e.,': 0.16; 'ordinal': 0.16; 'received:155.180': 0.16; 'received:159.53': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'subject:unicode': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'wrote:': 0.17; 'fix': 0.17; 'unicode': 0.17; 'previously': 0.18; 'to:name:python-list@python.org': 0.20; 'trying': 0.21; 'parse': 0.22; 'task': 0.23; 'to:2**1': 0.23; "i've": 0.23; 'received:169.254': 0.24; 'script': 0.24; 'tried': 0.25; 'header :In-Reply-To:1': 0.25; 'skip:" 20': 0.26; '(most': 0.27; '(as': 0.27; '2.6': 0.27; 'accuracy': 0.27; 'outlook': 0.28; 'run': 0.28; 'character': 0.29; 'convert': 0.29; 'objects': 0.29; 'received:169': 0.29; "i'm": 0.29; 'e.g.': 0.30; 'link.': 0.30; 'error': 0.30; 'figure': 0.30; 'code': 0.31; 'url:python': 0.32; 'file': 0.32; 'print': 0.32; 'getting': 0.33; 'docs': 0.33; 'traceback': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'that,': 0.34; "can't": 0.34; 'list': 0.35; 'clear': 0.35; 'doing': 0.35; 'subject:?': 0.35; 'something': 0.35; 'list.': 0.35; 'but': 0.36; 'url:org': 0.36; 'characters': 0.36; 'url:library': 0.36; 'charset:us-ascii': 0.36; 'display': 0.36; 'subject:: ': 0.38; 'store': 0.38; 'supports': 0.38; 'some': 0.38; 'url:docs': 0.38; 'description': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'skip:u 10': 0.60; 'containing': 0.61; 'telling': 0.61; 'free': 0.61; 'information,': 0.63; 'url:email': 0.63; 'legal': 0.65; 'results': 0.65; 'tasks.': 0.65; 'subject': 0.66; 'purchase': 0.67; 'sale': 0.76; 'received:169.254.8': 0.84; 'aka': 0.91; 'online,': 0.98 X-DKIM: OpenDKIM Filter v2.1.3 sf1.jpmchase.com qA7N8pSh018698 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1352329731; bh=DfxAW0QOilK1l2W8KtkH9OTNG+i5pC9M7cZPX9w34KI=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=KlMFJ29vELQ1tmf5tEo4uYeVhJ7082CjTv9Te1xYapRagw4Bkc42TMyT6JbYZ5z9G 1rrkwD2uQVKWhy37K55egd5iT0wKN9IuMqFTGpznfoqxf3l3WfkyJpBcV9ERAcn7jv 0PbltJ4D3YMnhCPc8DUqYIHBCP/hQzYhMGOXQ1cQ= From: "Prasad, Ramit" To: Anders , "python-list@python.org" Subject: RE: Right solution to unicode error? Thread-Topic: Right solution to unicode error? Thread-Index: AQHNvTeM/xR6HEvFT06wM53mT6A/j5fe/e2A Date: Wed, 7 Nov 2012 23:07:33 +0000 References: <09a3d20b-5871-47f4-9218-df119698e405@m4g2000yqf.googlegroups.com> In-Reply-To: <09a3d20b-5871-47f4-9218-df119698e405@m4g2000yqf.googlegroups.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.79.47] Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-DLP-FWD: Yes Content-Type: text/plain; charset="us-ascii" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352329734 news.xs4all.nl 6893 [2001:888:2000:d::a6]:57712 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32912 Anders wrote:=0D=0A> =0D=0A> I've run into a Unicode error, and despite doi= ng some googling, I=0D=0A> can't figure out the right way to fix it=2E I ha= ve a Python 2=2E6 script=0D=0A> that reads my Outlook 2010 task list=2E I'm= able to read the tasks from=0D=0A> Outlook and store them as a list of obj= ects without a hitch=2E But when=0D=0A> I try to print the tasks' subjects= , one of the tasks is generating an=0D=0A> error:=0D=0A> =0D=0A> Traceback = (most recent call last):=0D=0A> File "outlook_tasks=2Epy", line 66, in =0D=0A> my_tasks=2Edump_today_tasks()=0D=0A> File "C:\Users\And= ers\code\Task List\tasks=2Epy", line 29, in=0D=0A> dump_today_tasks=0D=0A> = print task=2Esubject=0D=0A> UnicodeEncodeError: 'ascii' codec can't enc= ode character u'\u2013' in=0D=0A> position 42: ordinal not in range(128)=0D= =0A> =0D=0A> (where task=2Esubject was previously assigned the value of=0D= =0A> task=2ESubject, aka the Subject property of an Outlook 2010 TaskItem)= =0D=0A> =0D=0A> From what I understand from reading online, the error is te= lling me=0D=0A> that the subject line contains an en dash and that Python = is trying=0D=0A> to convert to ascii and failing (as it should)=2E=0D=0A> = =0D=0A> Here's where I'm getting stuck=2E In the code above I was just pri= nting=0D=0A> the subject so I can see whether the script is working properl= y=2E=0D=0A> Ultimately what I want to do is parse the tasks I'm interested = in and=0D=0A> then create an HTML file containing those tasks=2E Given tha= t, what's=0D=0A> the best way to fix this problem?=0D=0A> =0D=0A> BTW, if t= here's a clear description of the best solution for this=0D=0A> particular = problem - i=2Ee=2E, where I want to ultimately display the=0D=0A> results a= s HTML - please feel free to refer me to the link=2E I tried=0D=0A> reading= a number of docs on the web but still feel pretty lost=2E=0D=0A> =0D=0A=0D= =0AYou can always encode in a non-ASCII codec=2E =0D=0A`print task=2Esubjec= t=2Eencode()` where is something that=0D=0Asupports th= e characters you want e=2Eg=2E latin1=2E =0D=0A=0D=0AThe list of built in c= odecs can be found:=0D=0Ahttp://docs=2Epython=2Eorg/library/codecs=2Ehtml#s= tandard-encodings=0D=0A=0D=0A=0D=0A~Ramit=0D=0A=0D=0A=0D=0A=0D=0AThis email= is confidential and subject to important disclaimers and=0D=0Aconditions i= ncluding on offers for the purchase or sale of=0D=0Asecurities, accuracy an= d completeness of information, viruses,=0D=0Aconfidentiality, legal privile= ge, and legal entity disclaimers,=0D=0Aavailable at http://www=2Ejpmorgan= =2Ecom/pages/disclosures/email=2E