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


Groups > comp.lang.python > #10241

Re: Help with Latin Characters

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 <bsk16@case.edu>
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 <CA+cji+5RKyZOY6wX_xWv01oasdHVvVJwVH+Z0_yXZc4=Qd9p5A@mail.gmail.com>
References <CA+cji+758J7KEuJ81SF2pfeQp15k5EtE9TvhNC9JgJK2nCGtrw@mail.gmail.com> <j0hobh$b32$1@dough.gmane.org> <CA+cji+7C9kg7owD2bga5vwWCa-_bZ9SXoZKQJc4m7YK+A9ptoQ@mail.gmail.com> <CA+cji+5rawWx1=zqteORPG0vHLbCV6G3o3RGWSCHYccLz8iq_A@mail.gmail.com> <CAPTjJmp_32FFCd-1HroX_6=QZQ=KkLC4uy2+GU0dv0niipKgEg@mail.gmail.com> <CA+cji+5RKyZOY6wX_xWv01oasdHVvVJwVH+Z0_yXZc4=Qd9p5A@mail.gmail.com>
Date Sun, 24 Jul 2011 23:35:48 -0400
Subject Re: Help with Latin Characters
From Benjamin Kaplan <benjamin.kaplan@case.edu>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1442.1311564965.1164.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Sun, Jul 24, 2011 at 3:47 PM, Joao Jacome <slyerex@gmail.com> wrote:
>
> 2011/7/24 Chris Angelico <rosuav@gmail.com>
>>
>> On Mon, Jul 25, 2011 at 5:01 AM, Joao Jacome <slyerex@gmail.com> 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 "Ê" becomes "Ê", 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
>

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


Thread

Re: Help with Latin Characters Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-07-24 23:35 -0400

csiph-web