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

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

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

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: >

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.

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

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

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

Re: encoding problem

2006-03-09 Thread Scott David Daniels
Yves Glodt wrote: > It seems in general I have trouble with special characters... > What is the python way to deal with éàè öäü etc... > > print 'é' fails here, This should probably stay true. > print u'é' as well :-( This is an issue with how your output is connected. What OS, what code page, wh

Re: encoding problem

2006-03-09 Thread Martin v. Löwis
Yves Glodt wrote: > It seems in general I have trouble with special characters... > What is the python way to deal with éàè öäü etc... > > print 'é' fails here, > print u'é' as well :-( > > How am I supposed to print non-ascii characters the correct way? The second form should be used, but not i

Re: encoding problem

2006-03-08 Thread Yves Glodt
Sebastjan Trepca wrote: > I think you are trying to concatenate a unicode string with regular > one so when it tries to convert the regular string to unicode with > ASCII(default one) encoding it fails. First find out which of these > strings is regular and how it was encoded, then you can decode i

Re: encoding problem

2006-03-03 Thread Sebastjan Trepca
I think you are trying to concatenate a unicode string with regular one so when it tries to convert the regular string to unicode with ASCII(default one) encoding it fails. First find out which of these strings is regular and how it was encoded, then you can decode it like this(if regular string is