"Kent Johnson" wrote in message
news:1c2a2c590905050337j1afc177ene64f800dcc3a7...@mail.gmail.com...
On Tue, May 5, 2009 at 1:14 AM, Mark Tolonen
wrote:
> The below works. ConfigParser isn't written to support Unicode
> correctly. I
> was able to get Unicode sections to write out, but it wa
On Tue, May 5, 2009 at 1:14 AM, Mark Tolonen wrote:
> The below works. ConfigParser isn't written to support Unicode correctly. I
> was able to get Unicode sections to write out, but it was just luck. Unicode
> keys and values break as the OP discovered. So treat everything as byte
> strings:
"spir" wrote in message
news:20090501220601.31891...@o...
Le Fri, 1 May 2009 15:19:29 -0300,
"Pablo P. F. de Faria" s'exprima ainsi:
self.cfg.write(codecs.open(self.properties_file,'w','utf-8'))
As one can see, the character encoding is explicitly UTF-8. But
ConfigParser keeps trying to sa
On Mon, May 4, 2009 at 3:54 PM, Sander Sweers wrote:
> 2009/5/4 Kent Johnson :
>> str.decode() converts a string to a unicode object. unicode.encode()
>> converts a unicode object to a (byte) string. Both of these functions
>> take the encoding as a parameter. When Python is given a string, but
>>
2009/5/4 Kent Johnson :
> str.decode() converts a string to a unicode object. unicode.encode()
> converts a unicode object to a (byte) string. Both of these functions
> take the encoding as a parameter. When Python is given a string, but
> it needs a unicode object, or vice-versa, it will encode or
Le Mon, 4 May 2009 11:09:25 -0300,
"Pablo P. F. de Faria" s'exprima ainsi:
> Thanks, Kent, but that doesn't solve my problem. In fact, I need
> ConfigParser to work with non-ascii characters, since my App may run
> in "latin-1" environments (folders e files names). I must find out why
> the str()
On Mon, May 4, 2009 at 1:32 PM, Pablo P. F. de Faria
wrote:
> Hi, all.
>
> I've found something that worked for me, but I'm not sure of its
> secureness. The solution is:
>
> reload(sys)
> sys.setdefaultencoding('utf-8')
>
> That's exactly what I wanted to do, but is this good practice?
No. You s
On Mon, May 4, 2009 at 10:09 AM, Pablo P. F. de Faria
wrote:
> Thanks, Kent, but that doesn't solve my problem. In fact, I need
> ConfigParser to work with non-ascii characters, since my App may run
> in "latin-1" environments (folders e files names).
Yes, I understand that.
Python has two diffe
Here is the traceback, after the last change you sugested:
Traceback (most recent call last):
File "/home/pablo/workspace/E-Dictor/src/MainFrame.py", line 1057, in OnClose
self.SavePreferences()
File "/home/pablo/workspace/E-Dictor/src/MainFrame.py", line 1069,
in SavePreferences
self.
Thanks, Kent, but that doesn't solve my problem. In fact, I need
ConfigParser to work with non-ascii characters, since my App may run
in "latin-1" environments (folders e files names). I must find out why
the str() function in the module ConfigParser doesn't use the encoding
defined for the applica
On Fri, May 1, 2009 at 4:54 PM, Pablo P. F. de Faria
wrote:
> Hi, Kent.
>
> The stack trace is:
>
> Traceback (most recent call last):
> File "/home/pablo/workspace/E-Dictor/src/MainFrame.py", line 1057, in OnClose
> self.SavePreferences()
> File "/home/pablo/workspace/E-Dictor/src/MainFrame.
Le Fri, 1 May 2009 15:19:29 -0300,
"Pablo P. F. de Faria" s'exprima ainsi:
> self.cfg.write(codecs.open(self.properties_file,'w','utf-8'))
>
> As one can see, the character encoding is explicitly UTF-8. But
> ConfigParser keeps trying to save it as a 'ascii' file and gives me
> error for directo
On Fri, May 1, 2009 at 2:19 PM, Pablo P. F. de Faria
wrote:
> Hi, all. I need some help.
>
> I'm trying to save a configuration file, using ConfigParser. The code
> is the following:
>
> self.cfg.write(codecs.open(self.properties_file,'w','utf-8'))
>
> As one can see, the character encoding is exp
Hi, all. I need some help.
I'm trying to save a configuration file, using ConfigParser. The code
is the following:
self.cfg.write(codecs.open(self.properties_file,'w','utf-8'))
As one can see, the character encoding is explicitly UTF-8. But
ConfigParser keeps trying to save it as a 'ascii' file
tly!
- Original Message -
From: Kent Johnson
To: Dinesh B Vadhia
Cc: tutor@python.org
Sent: Monday, April 14, 2008 3:42 AM
Subject: Re: [Tutor] encode unicode strings from pysqlite
Dinesh B Vadhia wrote:
> Here is a program that SELECT's from a pysqlite database table
Dinesh B Vadhia wrote:
> Here is a program that SELECT's from a pysqlite database table and
> encode's the returned unicode strings:
> query = "SELECT fieldB FROM testDB WHERE fieldB LIKE '%s' LIMIT '%s'"
> %(q, limit)
> for row in cur.execute(query):
Here row is a list containing a single unic
Here is a program that SELECT's from a pysqlite database table and encode's the
returned unicode strings:
import sys
import os
import sqlite3
con = sqlite3.connect("testDB.db")
cur = con.cursor()
a = u'99 Cycling Swords'
b = a.encode('utf-8')
print b
q = '%wor%'
limit = 25
query = "SELECT fiel
On Wed, 19 Apr 2006, kakada wrote:
> I wonder if we can check the encoding of text in one text file. user is
> free to encode the file whether Latin1, utf-8, ANSI...
In the general case, this is difficult, and "solving" it might be worse
than not. See:
http://www.joelonsoftware.com/art
On Wed, 2006-04-19 at 10:10 +0700, kakada wrote:
> Hi again folks,
>
> I wonder if we can check the encoding of text in one text file.
> user is free to encode the file whether Latin1, utf-8, ANSI...
> Any ideas?
def decode_file(filepath):
'''Order of codecs is important.
ASCII is most r
Hi again folks,
I wonder if we can check the encoding of text in one text file.
user is free to encode the file whether Latin1, utf-8, ANSI...
Any ideas?
Thx
da
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
tutor-request
Thanks Ziyad.You answer is exactly the realson it is! I am missdirect
by the coding of the html. the %25 in the url is the '%' char in file name.
after
urllib.unquote('xvg_h%25202.jpg')
'xvg_h%202.jpg'
That's the real filename I want!
thanks too, Danny Yoo!
>This has n
On Tue, 2005-09-27 at 14:01 +0800, 铁石 wrote:
> I am trying to write a stript that extract jpg files
> from a html I had downloaded.I encounter a problem with
> a Big5 charset html file.Big5 used in Hongkong ans Taiwan.
> In this html file there's a jpg names "xvg_h%202.jpg"
> in vi ,the
On Tue, 27 Sep 2005, [GB2312] ��ʯ wrote:
> I am trying to write a stript that extract jpg files
> from a html I had downloaded.I encounter a problem with
> a Big5 charset html file.Big5 used in Hongkong ans Taiwan.
> In this html file there's a jpg names "xvg_h%202.jpg" in vi ,the tag
I am trying to write a stript that extract jpg files
from a html I had downloaded.I encounter a problem with
a Big5 charset html file.Big5 used in Hongkong ans Taiwan.
In this html file there's a jpg names "xvg_h%202.jpg"
in vi ,the tag of the image is
24 matches
Mail list logo