Re: Another 2 to 3 mail encoding problem

2020-08-31 Thread Peter J. Holzer
On 2020-08-27 09:34:47 +0100, Chris Green wrote: > Peter J. Holzer wrote: > > The problem is that the message contains a '\ufeff' character (byte > > order mark) where email/generator.py expects only ASCII characters. > > > > I see two possible reasons for this: [...] > > Both reasons are weird.

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread MRAB
On 2020-08-27 17:29, Barry Scott wrote: On 26 Aug 2020, at 16:10, Chris Green wrote: UnicodeEncodeError: 'ascii' codec can't encode character '\ufeff' in position 4: ordinal not in range(128) So what do I need to do to the message I'm adding with mbx.add(msg) to fix this? (I assume that'

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Barry Scott
> On 26 Aug 2020, at 16:10, Chris Green wrote: > > UnicodeEncodeError: 'ascii' codec can't encode character '\ufeff' in > position 4: ordinal not in range(128) > > So what do I need to do to the message I'm adding with mbx.add(msg) to > fix this? (I assume that's what I need to do). >>> i

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Barry
> On 27 Aug 2020, at 10:40, Chris Green wrote: > > Karsten Hilbert wrote: >>> Terry Reedy wrote: > On 8/26/2020 11:10 AM, Chris Green wrote: > >> I have a simple[ish] local mbox mail delivery module as follows:- > ... >> It has run faultlessly for many years under Python

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Chris Green
Richard Damon wrote: > On 8/27/20 4:31 AM, Chris Green wrote: > > While an E-Mail body possibly *shouldn't* have non-ASCII characters in > > it one must be able to handle them without errors. In fact haven't > > the RFCs changed such that the message body should be 8-bit clean? > > Anyway I think

Aw: Re: Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Karsten Hilbert
> > > Because of this, the Python 3 str type is not suitable to store an email > > > message, since it insists on the string being Unicode encoded, > > > > I should greatly appreciate to be enlightened as to what > > a "string being Unicode encoded" is intended to say ? > > > > A Python 3 "str" or

Re: Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Chris Angelico
On Thu, Aug 27, 2020 at 11:10 PM Karsten Hilbert wrote: > > > Because of this, the Python 3 str type is not suitable to store an email > > message, since it insists on the string being Unicode encoded, > > I should greatly appreciate to be enlightened as to what > a "string being Unicode encoded"

Aw: Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Karsten Hilbert
> Because of this, the Python 3 str type is not suitable to store an email > message, since it insists on the string being Unicode encoded, I should greatly appreciate to be enlightened as to what a "string being Unicode encoded" is intended to say ? Thanks, Karsten -- https://mail.python.org/ma

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Richard Damon
On 8/27/20 4:31 AM, Chris Green wrote: > While an E-Mail body possibly *shouldn't* have non-ASCII characters in > it one must be able to handle them without errors. In fact haven't > the RFCs changed such that the message body should be 8-bit clean? > Anyway I think the Python 3 mail handling libr

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Chris Green
Karsten Hilbert wrote: > > Terry Reedy wrote: > > > On 8/26/2020 11:10 AM, Chris Green wrote: > > > > > > > I have a simple[ish] local mbox mail delivery module as follows:- > > > ... > > > > It has run faultlessly for many years under Python 2. I've now > > > > changed the calling program to Py

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Cameron Simpson
On 27Aug2020 09:31, Chris Green wrote: >I can provoke the error simply by sending myself an E-Mail with >accented characters in it. I'm pretty sure my Linux system is set up >correctly for UTF8 characters, I certainly seem to be able to send and >receive these to others and I even get to see mess

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Peter Otten
Chris Green wrote: > To add a little to this, the problem is definitely when I receive a > message with UTF8 (or at least non-ascci) characters in it. My code > is basically very simple, the main program reads an E-Mail message > received from .forward on its standard input and makes it into an m

Aw: Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Karsten Hilbert
> Terry Reedy wrote: > > On 8/26/2020 11:10 AM, Chris Green wrote: > > > > > I have a simple[ish] local mbox mail delivery module as follows:- > > ... > > > It has run faultlessly for many years under Python 2. I've now > > > changed the calling program to Python 3 and while it handles most > > >

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Chris Green
Peter J. Holzer wrote: > The problem is that the message contains a '\ufeff' character (byte > order mark) where email/generator.py expects only ASCII characters. > > I see two possible reasons for this: > > * The mbox writing code assumes that all messages with non-ascii >characters are QP

Re: Another 2 to 3 mail encoding problem

2020-08-27 Thread Chris Green
Terry Reedy wrote: > On 8/26/2020 11:10 AM, Chris Green wrote: > > > I have a simple[ish] local mbox mail delivery module as follows:- > ... > > It has run faultlessly for many years under Python 2. I've now > > changed the calling program to Python 3 and while it handles most > > E-Mail OK I ha

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Terry Reedy
On 8/26/2020 11:10 AM, Chris Green wrote: I have a simple[ish] local mbox mail delivery module as follows:- ... It has run faultlessly for many years under Python 2. I've now changed the calling program to Python 3 and while it handles most E-Mail OK I have just got the following error:-

Unsubscrip (Re: Another 2 to 3 mail encoding problem)

2020-08-26 Thread Terry Reedy
On 8/26/2020 11:27 AM, Alexa Oña wrote: Don’t send me more emails -- https://mail.python.org/mailman/listinfo/python-list Unsubscribe yourself by going to the indicated url. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Michael Torrie
On 8/26/20 9:27 AM, Alexa Oña wrote: > Don’t send me more emails > > https://mail.python.org/mailman/listinfo/python-list ^ Please unsubscribe from the mailing list. Click on the link above. Thank you. -- https://mail.python.org/mailman/listinfo/pyth

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Peter J. Holzer
On 2020-08-26 16:10:35 +0100, Chris Green wrote: > I'm unearthing a few issues here trying to convert my mail filter and > delivery programs from 2 to 3! > > I have a simple[ish] local mbox mail delivery module as follows:- > [...] > class mymbox(mailbox.mbox): > def _pre_message_ho

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Python
Alexa Oña wrote: Don’t send me more emails Obtener Outlook para iOS You are the one spamming the mailing list with unrelated posts. STOP. -- https://mail.python.org/mailman/listinfo/python-list

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Chris Green
To add a little to this, the problem is definitely when I receive a message with UTF8 (or at least non-ascci) characters in it. My code is basically very simple, the main program reads an E-Mail message received from .forward on its standard input and makes it into an mbox message as follows:-

Re: Another 2 to 3 mail encoding problem

2020-08-26 Thread Alexa Oña
Don’t send me more emails Obtener Outlook para iOS<https://aka.ms/o0ukef> De: Python-list en nombre de Chris Green Enviado: Wednesday, August 26, 2020 5:10:35 PM Para: python-list@python.org Asunto: Another 2 to 3 mail encoding problem I'm unear

Another 2 to 3 mail encoding problem

2020-08-26 Thread Chris Green
I'm unearthing a few issues here trying to convert my mail filter and delivery programs from 2 to 3! I have a simple[ish] local mbox mail delivery module as follows:- import mailbox import logging import logging.handlers import os import time # # # Class derived

Re: Encoding problem in python

2013-08-21 Thread electron
If you use Arabic frequently on your system, I suggest to change your windows system locale from "Region and Language" in control panel (Administrative tab) and set to Arabic. -- http://mail.python.org/mailman/listinfo/python-list

Re: Encoding problem in python

2013-03-04 Thread Vlastimil Brom
2013/3/4 : > I have a problem with encoding in python 27 shell. > > when i write this in the python shell: > > w=u'العربى' > > It gives me the following error: > > Unsupported characters in input > > any help? > -- > http://mail.python.org/mailman/listinfo/python-list Hi, I guess, you are using

Re: Encoding problem in python

2013-03-04 Thread Steven D'Aprano
On Mon, 04 Mar 2013 01:37:42 -0800, yomnasalah91 wrote: > I have a problem with encoding in python 27 shell. > > when i write this in the python shell: > > w=u'العربى' > > It gives me the following error: > > Unsupported characters in input > > any help? Firstly, please show the COMPLETE err

Re: Encoding problem in python

2013-03-04 Thread Laszlo Nagy
On 2013-03-04 10:37, yomnasala...@gmail.com wrote: I have a problem with encoding in python 27 shell. when i write this in the python shell: w=u'العربى' It gives me the following error: Unsupported characters in input any help? Maybe it is not Python related. Did you get an exception? Can yo

Encoding problem in python

2013-03-04 Thread yomnasalah91
I have a problem with encoding in python 27 shell. when i write this in the python shell: w=u'العربى' It gives me the following error: Unsupported characters in input any help? -- http://mail.python.org/mailman/listinfo/python-list

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-08 Thread Nobody
On Wed, 05 Oct 2011 21:39:17 -0700, Greg wrote: > Here is the final code for those who are struggling with similar > problems: > > ## open and decode file > # In this case, the encoding comes from the charset argument in a meta > tag > # e.g. > fileObj = open(filePath,"r").read() > fileContent =

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-06 Thread John Gordon
In xDog Walker writes: > What is this io of which you speak? It was introduced in Python 2.6. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashl

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-06 Thread xDog Walker
On Thursday 2011 October 06 10:41, jmfauth wrote: > or  (Python2/Python3) > > >>> import io > >>> with io.open('abc.txt', 'r', encoding='iso-8859-2') as f: > > ...     r = f.read() > ... > > >>> repr(r) > > u'a\nb\nc\n' > > >>> with io.open('def.txt', 'w', encoding='utf-8-sig') as f: > > ...     t

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-06 Thread jmfauth
On 6 oct, 06:39, Greg wrote: > Brilliant! It worked. Thanks! > > Here is the final code for those who are struggling with similar > problems: > > ## open and decode file > # In this case, the encoding comes from the charset argument in a meta > tag > # e.g. > fileObj = open(filePath,"r").read() >

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-06 Thread Chris Angelico
On Thu, Oct 6, 2011 at 8:29 PM, Ulrich Eckhardt wrote: > Just wondering, why do you split the latter two parts? I would have used > codecs.open() to open the file and define the encoding in a single step. Is > there a downside to this approach? > Those two steps still happen, even if you achieve

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-06 Thread Ulrich Eckhardt
Am 06.10.2011 05:40, schrieb Steven D'Aprano: (4) Do all your processing in Unicode, not bytes. (5) Encode the text into bytes using UTF-8 encoding. (6) Write the bytes to a file. Just wondering, why do you split the latter two parts? I would have used codecs.open() to open the file and defi

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Chris Angelico
On Thu, Oct 6, 2011 at 3:39 PM, Greg wrote: > Brilliant! It worked. Thanks! > > Here is the final code for those who are struggling with similar > problems: > > ## open and decode file > # In this case, the encoding comes from the charset argument in a meta > tag > # e.g. > fileContent = fileObj.

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Greg
Brilliant! It worked. Thanks! Here is the final code for those who are struggling with similar problems: ## open and decode file # In this case, the encoding comes from the charset argument in a meta tag # e.g. fileObj = open(filePath,"r").read() fileContent = fileObj.decode("iso-8859-2") fileSo

Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Steven D'Aprano
On Wed, 05 Oct 2011 16:35:59 -0700, Greg wrote: > Hi, I am having some encoding problems when I first parse stuff from a > non-english website using BeautifulSoup and then write the results to a > txt file. If you haven't already read this, you should do so: http://www.joelonsoftware.com/article

encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Greg
Hi, I am having some encoding problems when I first parse stuff from a non-english website using BeautifulSoup and then write the results to a txt file. I have the text both as a normal (text) and as a unicode string (utext): print repr(text) 'Branie zak\xc2\xb3adnik\xc3\xb3w' print repr(utext) u

Re: the stupid encoding problem to stdout

2011-06-13 Thread Chris Angelico
2011/6/14 Sérgio Monteiro Basto : > And see, I can send ascii and utf-8 to utf-8 output and never have problems, > but if I send ascii and utf-8 to ascii files sometimes got encode errors. > If something fits inside 7-bit ASCII, it is by definition valid UTF-8. This is not a coincidence. Those ho

Re: the stupid encoding problem to stdout

2011-06-13 Thread Sérgio Monteiro Basto
Ian Kelly wrote: > If you want your output to behave that way, then all you have to do is > specify that with an explicit encode step. ok >> If we want we change default for whatever we want, but without this >> "default change" Python should not change his behavior depending on >> output. yeah

Re: the stupid encoding problem to stdout

2011-06-10 Thread Chris Angelico
2011/6/11 Sérgio Monteiro Basto : > ok after thinking about this, this problem exist because Python want be > smart with ttys The *anomaly* (not problem) exists because Python has a way of being told a target encoding. If two parties agree on an encoding, they can send characters to each other. I

Re: the stupid encoding problem to stdout

2011-06-10 Thread Ian Kelly
2011/6/10 Sérgio Monteiro Basto : > ok after thinking about this, this problem exist because Python want be > smart with ttys, which is in my point of view is wrong, should not encode to > utf-8, because tty is in utf-8. Python should always encode to the same > thing. If the default is ascii, shou

Re: the stupid encoding problem to stdout

2011-06-10 Thread Sérgio Monteiro Basto
Ben Finney wrote: >> > What should it decode to, then? >> >> UTF-8, as in tty > > But when you explicitly redirect to a file, it's not going to a TTY. > It's going to a file whose encoding isn't known unless you specify it. ok after thinking about this, this problem exist because Python want be

Re: the stupid encoding problem to stdout

2011-06-09 Thread Laurent Claessens
Le 09/06/2011 04:18, Sérgio Monteiro Basto a écrit : > hi, > cat test.py > #!/usr/bin/env python > #-*- coding: utf-8 -*- > u = u'moçambique' > print u.encode("utf-8") > print u > > chmod +x test.py > ../test.py > moçambique > moçambique The following tries to encode before to print. If you pass

Re: the stupid encoding problem to stdout

2011-06-09 Thread Laurent Claessens
Le 09/06/2011 04:18, Sérgio Monteiro Basto a écrit : > hi, > cat test.py > #!/usr/bin/env python > #-*- coding: utf-8 -*- > u = u'moçambique' > print u.encode("utf-8") > print u > > chmod +x test.py > ../test.py > moçambique > moçambique The following tries to encode before to print. If you pass

Re: the stupid encoding problem to stdout

2011-06-09 Thread Laurent Claessens
Le 09/06/2011 04:18, Sérgio Monteiro Basto a écrit : > hi, > cat test.py > #!/usr/bin/env python > #-*- coding: utf-8 -*- > u = u'moçambique' > print u.encode("utf-8") > print u > > chmod +x test.py > ../test.py > moçambique > moçambique The following tries to encode before to print. If you pass

Re: the stupid encoding problem to stdout

2011-06-09 Thread Sérgio Monteiro Basto
Ben Finney wrote: >> >> Exactly the opposite , if python don't know the encoding should not >> >> try decode to ASCII. > > Are you advocating that Python should refuse to write characters unless > the encoding is specified? I could sympathise with that, but currently > that's not what Python does

Re: the stupid encoding problem to stdout

2011-06-09 Thread Ben Finney
Sérgio Monteiro Basto writes: > Nobody wrote: > > >> Exactly the opposite , if python don't know the encoding should not > >> try decode to ASCII. Are you advocating that Python should refuse to write characters unless the encoding is specified? I could sympathise with that, but currently that's

Re: the stupid encoding problem to stdout

2011-06-09 Thread Sérgio Monteiro Basto
Mark Tolonen wrote: > > "Sérgio Monteiro Basto" wrote in message > news:4df137a7$0$30580$a729d...@news.telepac.pt... > >> How I change sys.stdout.encoding always to UTF-8 ? at least have a >> consistent sys.stdout.encoding > > There is an environment variable that can force Python I/O to be a

Re: the stupid encoding problem to stdout

2011-06-09 Thread Sérgio Monteiro Basto
Nobody wrote: >> Exactly the opposite , if python don't know the encoding should not try >> decode to ASCII. > > What should it decode to, then? UTF-8, as in tty, how I change this default ? > You can't write characters to a stream, only bytes. > ok got the point . Thanks, -- http://mail.p

Re: the stupid encoding problem to stdout

2011-06-09 Thread Mark Tolonen
"Sérgio Monteiro Basto" wrote in message news:4df137a7$0$30580$a729d...@news.telepac.pt... How I change sys.stdout.encoding always to UTF-8 ? at least have a consistent sys.stdout.encoding There is an environment variable that can force Python I/O to be a specfic encoding: PYTHONIOEN

Re: the stupid encoding problem to stdout

2011-06-09 Thread Terry Reedy
On 6/9/2011 5:46 PM, Nobody wrote: On Thu, 09 Jun 2011 22:14:17 +0100, Sérgio Monteiro Basto wrote: Exactly the opposite , if python don't know the encoding should not try decode to ASCII. What should it decode to, then? You can't write characters to a stream, only bytes. I want python don

Re: the stupid encoding problem to stdout

2011-06-09 Thread Ben Finney
Sérgio Monteiro Basto writes: > Ben Finney wrote: > > > In this case your shell has no preference for the encoding (since > > you're redirecting output to a file). > > How I say to python that I want that write in utf-8 to files ? You already did: > > In the first print statement you specify t

Re: the stupid encoding problem to stdout

2011-06-09 Thread Nobody
On Thu, 09 Jun 2011 22:14:17 +0100, Sérgio Monteiro Basto wrote: > Exactly the opposite , if python don't know the encoding should not try > decode to ASCII. What should it decode to, then? You can't write characters to a stream, only bytes. > I want python don't care about encoding terminal a

Re: the stupid encoding problem to stdout

2011-06-09 Thread Sérgio Monteiro Basto
Ben Finney wrote: > Sérgio Monteiro Basto writes: > >> ./test.py >> moçambique >> moçambique > > In this case your terminal is reporting its encoding to Python, and it's > capable of taking the UTF-8 data that you send to it in both cases. > >> ./test.py > output.txt >> Traceback (most recent

Re: the stupid encoding problem to stdout

2011-06-09 Thread Sérgio Monteiro Basto
Benjamin Kaplan wrote: > 2011/6/8 Sérgio Monteiro Basto : >> hi, >> cat test.py >> #!/usr/bin/env python >> #-*- coding: utf-8 -*- >> u = u'moçambique' >> print u.encode("utf-8") >> print u >> >> chmod +x test.py >> ./test.py >> moçambique >> moçambique >> >> ./test.py > output.txt >> Traceback (m

Re: the stupid encoding problem to stdout

2011-06-08 Thread Benjamin Kaplan
2011/6/8 Sérgio Monteiro Basto : > hi, > cat test.py > #!/usr/bin/env python > #-*- coding: utf-8 -*- > u = u'moçambique' > print u.encode("utf-8") > print u > > chmod +x test.py > ./test.py > moçambique > moçambique > > ./test.py > output.txt > Traceback (most recent call last): >  File "./test.py

Re: the stupid encoding problem to stdout

2011-06-08 Thread Ben Finney
Sérgio Monteiro Basto writes: > ./test.py > moçambique > moçambique In this case your terminal is reporting its encoding to Python, and it's capable of taking the UTF-8 data that you send to it in both cases. > ./test.py > output.txt > Traceback (most recent call last): > File "./test.py", li

the stupid encoding problem to stdout

2011-06-08 Thread Sérgio Monteiro Basto
hi, cat test.py #!/usr/bin/env python #-*- coding: utf-8 -*- u = u'moçambique' print u.encode("utf-8") print u chmod +x test.py ./test.py moçambique moçambique ./test.py > output.txt Traceback (most recent call last): File "./test.py", line 5, in print u UnicodeEncodeError: 'ascii' codec

Re: Encoding problem when launching Python27 via DOS

2011-04-11 Thread Jean-Pierre M
Thanks a lot for this quick answer! It is very clear! Ti better understand what the difference between encoding and decoding is I found the following website: http://www.evanjones.ca/python-utf8.html I change the program to (changes are in bold): *# -*- c

Re: Encoding problem when launching Python27 via DOS

2011-04-10 Thread MRAB
On 10/04/2011 13:22, Jean-Pierre M wrote: > I created a simple program which writes in a unicode files some french text with accents! [snip] This line: l.p("premier message de Log à accents") passes a bytestring to the method, and inside the method, this line: unicode_str=u'%s : %s \n

Encoding problem when launching Python27 via DOS

2011-04-10 Thread Jean-Pierre M
I created a simple program which writes in a unicode files some french text with accents! *# -*- coding: cp1252 -*-* *#!/usr/bin/python* *'''* *Created on 27 déc. 2010* * * *@author: jpmena* *'''* *from datetime import datetime* *import locale* *import codecs* *import os,sys* * * *class Log(object)

Re: nntplib encoding problem

2011-02-28 Thread Laurent Duchesne
Hi, Thanks it's working! But is it "normal" for a string coming out of a module (nntplib) to crash when passed to print or write? I'm just asking to know if I should open a bug report or not :) I'm also wondering which strings should be re-encoded using the surrogateescape parameter and whic

Re: nntplib encoding problem

2011-02-27 Thread Thomas L. Shinnick
At 08:12 PM 2/27/2011, you wrote: On 28/02/2011 01:31, Laurent Duchesne wrote: Hi, I'm using python 3.2 and got the following error: nntpClient = nntplib.NNTP_SSL(...) nntpClient.group("alt.binaries.cd.lossless") nntpClient.over((534157,534157)) ... 'subject': 'Myl\udce8ne Farmer - Anamorpho

Re: nntplib encoding problem

2011-02-27 Thread MRAB
On 28/02/2011 01:31, Laurent Duchesne wrote: Hi, I'm using python 3.2 and got the following error: nntpClient = nntplib.NNTP_SSL(...) nntpClient.group("alt.binaries.cd.lossless") nntpClient.over((534157,534157)) ... 'subject': 'Myl\udce8ne Farmer - Anamorphosee (Japan Edition) 1995 [02/41] "B

nntplib encoding problem

2011-02-27 Thread Laurent Duchesne
Hi, I'm using python 3.2 and got the following error: nntpClient = nntplib.NNTP_SSL(...) nntpClient.group("alt.binaries.cd.lossless") nntpClient.over((534157,534157)) ... 'subject': 'Myl\udce8ne Farmer - Anamorphosee (Japan Edition) 1995 [02/41] "Back.jpg" yEnc (1/3)' ... overview = nntpClien

Re: Encoding problem - or bug in couchdb-0.8-py2.7.egg??

2010-09-20 Thread Ian
Thanks Diez, Removing, rebooting and installing the latest version solved the problem. :) Your google-foo is better than mine. Google had not turned that up for me. Thanks again Regards Ian On 20/09/2010 17:00, Diez B. Roggisch wrote: Ian Hobson writes: Hi all, I have hit a probl

Re: Encoding problem - or bug in couchdb-0.8-py2.7.egg??

2010-09-20 Thread Diez B. Roggisch
Ian Hobson writes: > Hi all, > > I have hit a problem and I don't know enough about python to diagnose > things further. Trying to use couchDB from Python. This script:- > > # coding=utf8 > import couchdb > from couchdb.client import Server > server = Server() > dbName = 'python-tests' > try: >

Encoding problem - or bug in couchdb-0.8-py2.7.egg??

2010-09-20 Thread Ian Hobson
Hi all, I have hit a problem and I don't know enough about python to diagnose things further. Trying to use couchDB from Python. This script:- # coding=utf8 import couchdb from couchdb.client import Server server = Server() dbName = 'python-tests' try: db = server.create(dbName) except cou

Re: encoding problem

2009-06-28 Thread Martin v. Löwis
> That is the reason why we have to explicitly declare a encoding as > long as we have non-ASCII in source. True - but it doesn't have to be the "correct" encoding. If you declared your source as latin-1, the effect is the same on byte string literals, but not on Unicode literals. In that sense,

Re: encoding problem

2009-06-27 Thread dejan todorović
It was problem with pymssql that not supports unicode, switched to pyodbc, everything is fine. Thanks for your swift reply. ;) On Jun 27, 7:44 pm, Piet van Oostrum wrote: > > netpork (n) wrote: > >n> Hello, > >n> I have ssl socket with server and client, on my development machine > >n> ev

Re: encoding problem

2009-06-27 Thread Piet van Oostrum
> netpork (n) wrote: >n> Hello, >n> I have ssl socket with server and client, on my development machine >n> everything works pretty well. >n> Database which I have to use is mssql on ms server 2003, so I decided >n> to install the same python config there and run my python server >n> script.

encoding problem

2009-06-27 Thread netpork
Hello, I have ssl socket with server and client, on my development machine everything works pretty well. Database which I have to use is mssql on ms server 2003, so I decided to install the same python config there and run my python server script. Now here is the problem, server is returning stra

Re: SyntaxError: encoding problem: with BOM

2008-12-26 Thread NoName
On 26 дек, 23:08, "Gabriel Genellina" wrote: > En Thu, 25 Dec 2008 11:55:16 -0200, NoName escribió: > > > Error > > > > C:\Documents and Settings\Ra\Рабочий стол>11.py > > File "", line 1 > > SyntaxError: encoding problem: with B

Re: SyntaxError: encoding problem: with BOM

2008-12-26 Thread Gabriel Genellina
En Thu, 25 Dec 2008 11:55:16 -0200, NoName escribió: Error C:\Documents and Settings\Ra\Рабочий стол>11.py File "", line 1 SyntaxError: encoding problem: with BOM No error C:\Documents and Settings\Ra\Рабочий стол>python 11.py test Error when russian symbols in

Re: SyntaxError: encoding problem: with BOM

2008-12-25 Thread NoName
> It's a bug, please report it. I though we fixed all Windows path bugs > for 3.0 but apparently one slipped through. > > Christian It is too difficult for me. please help me=) -- http://mail.python.org/mailman/listinfo/python-list

Re: SyntaxError: encoding problem: with BOM

2008-12-25 Thread Christian Heimes
> sorry:) > > Now i know where problem. > But i dont know how to solve it. > > Error > > C:\Documents and Settings\Ra\Рабочий стол>11.py > File "", line 1 > SyntaxError: encoding problem: with BOM > > No error > > C:\Documents and Se

Re: SyntaxError: encoding problem: with BOM

2008-12-25 Thread NoName
dont know how to solve it. Error C:\Documents and Settings\Ra\Рабочий стол>11.py File "", line 1 SyntaxError: encoding problem: with BOM No error C:\Documents and Settings\Ra\Рабочий стол>python 11.py test Error when russian symbols in full path to py-script. Is i

Re: SyntaxError: encoding problem: with BOM

2008-12-25 Thread John Machin
encoding: > > >>> # -*- coding: cp866 -*- > > >>> print ("ff") > > >>> It's not work in Python 3.0 > > >>> Error: > > >>> File "", line 1 > > >>> SyntaxError: encoding problem: wit

Re: SyntaxError: encoding problem: with BOM

2008-12-25 Thread NoName
> print ("ff") > >>> It's not work in Python 3.0 > >>> Error: > >>> File "", line 1 > >>> SyntaxError: encoding problem: with BOM > >>> what's wrong? > >> I can only guess, but just because you write

Re: SyntaxError: encoding problem: with BOM

2008-12-24 Thread Diez B. Roggisch
NoName schrieb: On 25 дек, 00:37, "Diez B. Roggisch" wrote: NoName schrieb: i have 1.py in cp866 encoding: # -*- coding: cp866 -*- print ("ff") It's not work in Python 3.0 Error: File "", line 1 SyntaxError: encoding problem: with BOM what's wrong?

Re: SyntaxError: encoding problem: with BOM

2008-12-24 Thread NoName
On 25 дек, 00:37, "Diez B. Roggisch" wrote: > NoName schrieb: > > > i have 1.py in cp866 encoding: > > > # -*- coding: cp866 -*- > > print ("ff") > > > It's not work in Python 3.0 > > Error: > > > File "", line

Re: SyntaxError: encoding problem: with BOM

2008-12-24 Thread Diez B. Roggisch
NoName schrieb: i have 1.py in cp866 encoding: # -*- coding: cp866 -*- print ("ff") It's not work in Python 3.0 Error: File "", line 1 SyntaxError: encoding problem: with BOM what's wrong? I can only guess, but just because you write the coding-header that

SyntaxError: encoding problem: with BOM

2008-12-24 Thread NoName
i have 1.py in cp866 encoding: # -*- coding: cp866 -*- print ("ff") It's not work in Python 3.0 Error: File "", line 1 SyntaxError: encoding problem: with BOM what's wrong? -- http://mail.python.org/mailman/listinfo/python-list

Re: encoding problem

2008-12-20 Thread Marc 'BlackJack' Rintsch
On Fri, 19 Dec 2008 16:50:39 -0700, Joe Strout wrote: > Marc 'BlackJack' Rintsch wrote: > And does REALbasic really use byte strings plus an encoding!? >>> You betcha! Works like a dream. >> >> IMHO a strange design decision. > > I get that you don't grok it, but I think that's because yo

Re: encoding problem

2008-12-19 Thread Joe Strout
Marc 'BlackJack' Rintsch wrote: I don't see the shortcoming in Python <3.0. If you want real strings with characters instead of just a bunch of bytes simply use `unicode` objects instead of `str`. Fair enough -- that certainly is the best policy. But working with any other encoding (sometimes

Re: encoding problem

2008-12-19 Thread John Machin
On Dec 20, 10:02 am, Marc 'BlackJack' Rintsch wrote: > On Fri, 19 Dec 2008 15:20:08 -0700, Joe Strout wrote: > > Marc 'BlackJack' Rintsch wrote: > > >>> And because strings in Python, unlike in (say) REALbasic, do not know > >>> their encoding -- they're just a string of bytes.  If they were a > >

Re: encoding problem

2008-12-19 Thread Marc 'BlackJack' Rintsch
On Fri, 19 Dec 2008 15:20:08 -0700, Joe Strout wrote: > Marc 'BlackJack' Rintsch wrote: > >>> And because strings in Python, unlike in (say) REALbasic, do not know >>> their encoding -- they're just a string of bytes. If they were a >>> string of bytes PLUS an encoding, then every string would k

Re: encoding problem

2008-12-19 Thread Joe Strout
Marc 'BlackJack' Rintsch wrote: And because strings in Python, unlike in (say) REALbasic, do not know their encoding -- they're just a string of bytes. If they were a string of bytes PLUS an encoding, then every string would know what it is, and things like conversion to another encoding, or co

Re: encoding problem

2008-12-19 Thread Marc 'BlackJack' Rintsch
On Fri, 19 Dec 2008 08:20:07 -0700, Joe Strout wrote: > Marc 'BlackJack' Rintsch wrote: > >>> The question is why the Python interpreter use the default encoding >>> instead of "utf-8", which I explicitly declared in the source. >> >> Because the declaration is only for decoding unicode literals

Re: encoding problem

2008-12-19 Thread digisat...@gmail.com
On 12月19日, 下午9时34分, Marc 'BlackJack' Rintsch wrote: > On Fri, 19 Dec 2008 04:05:12 -0800, digisat...@gmail.com wrote: > > The below snippet code generates UnicodeDecodeError. > > #!/usr/bin/env > > python > > #--*-- coding: utf-8 --*-- > > s = 'äöü' > > u = unicode(s) > > > It seems that the syste

Re: encoding problem

2008-12-19 Thread Joe Strout
Marc 'BlackJack' Rintsch wrote: The question is why the Python interpreter use the default encoding instead of "utf-8", which I explicitly declared in the source. Because the declaration is only for decoding unicode literals in that very source file. And because strings in Python, unlike in

Re: encoding problem

2008-12-19 Thread Marc 'BlackJack' Rintsch
On Fri, 19 Dec 2008 04:05:12 -0800, digisat...@gmail.com wrote: > The below snippet code generates UnicodeDecodeError. > #!/usr/bin/env > python > #--*-- coding: utf-8 --*-- > s = 'äöü' > u = unicode(s) > > > It seems that the system use the default encoding- ASCII to decode the > utf8 encoded s

Re: encoding problem

2008-12-19 Thread Bruno Desthuilliers
digisat...@gmail.com a écrit : The below snippet code generates UnicodeDecodeError. #!/usr/bin/env python #--*-- coding: utf-8 --*-- s = 'äöü' u = unicode(s) It seems that the system use the default encoding- ASCII to decode the utf8 encoded string literal, and thus generates the error. Indee

encoding problem

2008-12-19 Thread digisat...@gmail.com
The below snippet code generates UnicodeDecodeError. #!/usr/bin/env python #--*-- coding: utf-8 --*-- s = 'äöü' u = unicode(s) It seems that the system use the default encoding- ASCII to decode the utf8 encoded string literal, and thus generates the error. The question is why the Python interpre

Re: encoding problem

2008-05-16 Thread Mike Driscoll
On May 16, 3:31 pm, Luis Zarrabeitia <[EMAIL PROTECTED]> wrote: > Hi, guys. > I'm trying to read an xml file and output some of the nodes. For that, I'm > doing a > print node.toprettyxml() > > However, I get this exception: > > === >     out.write(tag.toxml()) > UnicodeEncodeError: 'ascii' codec c

encoding problem

2008-05-16 Thread Luis Zarrabeitia
Hi, guys. I'm trying to read an xml file and output some of the nodes. For that, I'm doing a print node.toprettyxml() However, I get this exception: === out.write(tag.toxml()) UnicodeEncodeError: 'ascii' codec can't encode character u'\xba' in position 190: ordinal not in range(128) ===

Re: Encoding problem with web application (Paste+Mako)

2007-06-06 Thread Martin Skou
Rob Wolfe wrote: > > You have to know the encoding of user input and then you > can use ``input_encoding`` and ``output_encoding`` parameters > of ``Template``. Mako internally handles everything as Python unicode > objects. > For example: > > t = Template(filename="templ.mako", input_encoding="i

Re: Encoding problem with web application (Paste+Mako)

2007-06-06 Thread Rob Wolfe
[EMAIL PROTECTED] wrote: > Hi > > I have a problem with encoding non-ascii characters in a web > application. The application uses Paste and Mako. > > The code is here: http://www.webudkast.dk/demo.txt > > The main points are: > > After getting some user generated input using > paste.request.parse

Encoding problem with web application (Paste+Mako)

2007-06-06 Thread [EMAIL PROTECTED]
Hi I have a problem with encoding non-ascii characters in a web application. The application uses Paste and Mako. The code is here: http://www.webudkast.dk/demo.txt The main points are: After getting some user generated input using paste.request.parse_formvars, how should this be correctly save

  1   2   >