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


Groups > comp.lang.python > #10241 > unrolled thread

Re: Help with Latin Characters

Started byBenjamin Kaplan <benjamin.kaplan@case.edu>
First post2011-07-24 23:35 -0400
Last post2011-07-24 23:35 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#10241 — Re: Help with Latin Characters

FromBenjamin Kaplan <benjamin.kaplan@case.edu>
Date2011-07-24 23:35 -0400
SubjectRe: Help with Latin Characters
Message-ID<mailman.1442.1311564965.1164.python-list@python.org>
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
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web