MozillaCookieJar doesn't work as expect

2007-02-03 Thread davihigh
OS: WinXP, Python 2.4 latest version I found it doesn't actually load cookies from the exist cookies.txt. Instead, it generate a new one when visit that url. Who can help me check what's problem in following code? Many thanks in advance! cj = cookielib.MozillaCookieJar() cj.load("d:\\temp\\cooki

Re: print UTF-8 file with BOM

2005-12-23 Thread davihigh
FYI. I had just receive something from a friend, he give me following nice example! I have one more question on this: How to write if I want to specify locale other than current locale? For example, program runn on Korea locale system, and try reading a UTF-8 file that save chinese characters. --

print UTF-8 file with BOM

2005-12-22 Thread davihigh
Hi Friends: fileObj = codecs.open( filename, "r", "utf-8" ) u = fileObj.read() # Returns a Unicode string from the UTF-8 bytes in the file print u It says error: UnicodeEncodeError: 'gbk' codec can't encode character u'\ufeff' in position 0: illegal multiby

How convert text file between locale encoding and UTF-8?

2005-12-20 Thread davihigh
Dear Friends: Wondering that is there neat way to do "subject line" in Python? I am talking about Python 2.4 with Win32 extension installed. The locale can be any of ANSI defined, for example, zh_CN (CP936) or Korea (CP949) . I am not expert in Python, if you well note I will appreciate a