Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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; '(using': 0.05; 'typing': 0.05; '"""': 0.07; 'bytes.': 0.07; 'python': 0.08; '"hello': 0.09; 'filename': 0.09; 'output': 0.11; '25,': 0.12; 'am,': 0.13; 'wrote:': 0.15; "'hello": 0.16; 'different,': 0.16; 'differently,': 0.16; 'encode': 0.16; 'url:pastebin': 0.16; 'mon,': 0.16; 'pm,': 0.16; 'subject:Help': 0.17; 'bytes': 0.19; 'modify': 0.22; 'header:In-Reply-To:1': 0.22; 'code.': 0.22; 'works.': 0.23; 'world!': 0.23; 'appear': 0.23; 'changed': 0.25; 'string': 0.26; '(in': 0.26; 'tried': 0.27; 'url:mailman': 0.27; 'character': 0.28; 'message-id:@mail.gmail.com': 0.28; '24,': 0.29; 'interpret': 0.29; 'unicode': 0.29; 'sun,': 0.30; 'url:listinfo': 0.32; 'print': 0.32; 'source': 0.32; 'chris': 0.32; 'does': 0.32; 'to:addr:python-list': 0.34; 'there': 0.34; 'characters': 0.34; 'quite': 0.34; 'actual': 0.35; 'file': 0.36; 'url:python': 0.37; 'pull': 0.37; 'sequence': 0.37; 'but': 0.37; 'using': 0.37; 'another': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'url:org': 0.38; 'subject:: ': 0.38; 'size,': 0.38; 'should': 0.39; 'correctly': 0.39; 'ways': 0.39; 'subject:with': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.40; 'raw': 0.40; 'your': 0.60; 'database,': 0.68; 'exact': 0.69; 'soon': 0.73 MIME-Version: 1.0 In-Reply-To: References: Date: Sun, 24 Jul 2011 23:35:48 -0400 Subject: Re: Help with Latin Characters From: Benjamin Kaplan To: python-list@python.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Junkmail-Status: score=10/49, host=mpv1.tis.cwru.edu X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A020203.4E2CE49C.0043,ss=1,fgs=0, ip=209.85.213.54, so=2010-12-23 16:51:53, dmn=2009-09-10 00:05:08, mode=single engine X-Junkmail-IWF: false 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: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1311564965 news.xs4all.nl 23854 [2001:888:2000:d::a6]:54066 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10241 On Sun, Jul 24, 2011 at 3:47 PM, Joao Jacome wrote: > > 2011/7/24 Chris Angelico >> >> On Mon, Jul 25, 2011 at 5:01 AM, Joao Jacome wrote: >> > Already tried without unicode string in rootdir, same results. What if= try >> > using raw strings? >> >> Raw strings are just another way of typing them into your source code. >> There are different ways of writing string literals, but they produce >> the same string object: >> >> "Hello \\ world!\n" >> 'Hello \\ world!\n' >> """Hello \\ world! >> """ >> r"""Hello \ world! >> """ >> >> All these produce the exact same thing. But u"Hello \\ world!\n" is >> quite different, or (in Python 3) b"Hello \\ world!\n". >> >> ChrisA >> -- >> http://mail.python.org/mailman/listinfo/python-list > > http://pastebin.com/iQzPhpVh > Changed filename to rawstring, now python can retrieve the file's info. > Now in the database, character "=C3=8A" becomes "=C3=83=C5=A0", but if i = retrieve it in python and try to get file size, it works. > Is there a way to modify output to display correctly these characters? > Your database does not have characters. Your database has a sequence of bytes. Your terminal reads a sequence of bytes. If your terminal and your database interpret that sequence of bytes differently, you'll appear to have different characters even though ts the actual content of the string is the same. What you should do is decode the bytes into Unicode as soon as you pull them out of the database (using whatever encoding the database uses) and then encode them into your terminal's encoding right before you print them. > -- > http://mail.python.org/mailman/listinfo/python-list >