Re: [Tutor] UnicodeEncodeError in python

2014-09-11 Thread Peter Otten
Juan Christian wrote: > On Thu, Sep 11, 2014 at 5:23 PM, Peter Otten <__pete...@web.de> wrote: >> >> >> You are getting an *encoding* error, so this may be triggered when you >> are trying to print. Can you post the traceback? >> >> Also, what is your OS and what does >> >> $ python3 -c'import loc

Re: [Tutor] UnicodeEncodeError in python

2014-09-11 Thread Juan Christian
On Thu, Sep 11, 2014 at 5:23 PM, Peter Otten <__pete...@web.de> wrote: > > > You are getting an *encoding* error, so this may be triggered when you are > trying to print. Can you post the traceback? > > Also, what is your OS and what does > > $ python3 -c'import locale; print(locale.getpreferredenc

Re: [Tutor] UnicodeEncodeError in python

2014-09-11 Thread Peter Otten
Juan Christian wrote: > On Thu, Sep 11, 2014 at 4:39 PM, Juan Christian > wrote: >> >> Using 3.4.1 >> >> I did try: >> >> self.persona_name = unicode(personaname) >> self.persona_name = personaname.decode("utf-8") >> >> But didn't work! >> > > > Some of the chars that brakes the program: > > \

Re: [Tutor] UnicodeEncodeError in python

2014-09-11 Thread Juan Christian
On Thu, Sep 11, 2014 at 4:39 PM, Juan Christian wrote: > > Using 3.4.1 > > I did try: > > self.persona_name = unicode(personaname) > self.persona_name = personaname.decode("utf-8") > > But didn't work! > Some of the chars that brakes the program: \u0183 \u2020 \u0361 \u0649 And many others cra

Re: [Tutor] UnicodeEncodeError in python

2014-09-11 Thread Juan Christian
Forget to tell, sorry. I'm using Python 3.4.1 On Thu, Sep 11, 2014 at 3:53 PM, Sebastian Silva wrote: > Hi, > Python 2 suffers from these kinds of issues frequently. > > However Python 3 does not. > > Now, to deal with different encodings in Python 2 you need to cast to > unicode type, and then

[Tutor] UnicodeEncodeError in python

2014-09-11 Thread Juan Christian
I'm iterating through Steam users and friend lists. So, my program was working good, but then I got some UnicodeEncodeError randomly, I didn't know where was the problem, then I was checking the names that I got from the API by hand, and then I saw users with ™, ︻デ═一, ︻芫, º³® and tons of other

Re: [Tutor] UnicodeEncodeError: 'cp932' codec can't encode character '\xe9' in position

2012-03-11 Thread Peter Otten
Steven D'Aprano wrote: > glyph. He shouldn't get a UnicodeDecodeError when printing. I smell a > bug since print shouldn't be decoding anything. (At worst, it needs to > *encode*.) You have correctly derived the actual traceback ;) [Robert] > It starts to print until it hits the wonderful charac

Re: [Tutor] UnicodeEncodeError: 'cp932' codec can't encode character '\xe9' in position

2012-03-11 Thread Peter Otten
Robert Sjoblom wrote: > Okay, so here's a fun one. Since I'm on a japanese locale my native > encoding is cp932. I was thinking of writing a parser for a bunch of > text files, but I stumbled on even printing the contents due to ... > something. I don't know what encoding the text file uses, which

Re: [Tutor] UnicodeEncodeError: 'cp932' codec can't encode character '\xe9' in position

2012-03-11 Thread Steven D'Aprano
On Sat, Mar 10, 2012 at 08:03:18PM -0500, Dave Angel wrote: > There are just 256 possible characters in cp1252, and 256 in cp932. CP932 is also known as MS-KANJI or SHIFT-JIS (actually, one of many variants of SHIFT-JS). It is a multi-byte encoding, which means it has far more than 256 characte

Re: [Tutor] UnicodeEncodeError: 'cp932' codec can't encode character '\xe9' in position

2012-03-10 Thread Robert Sjoblom
> You can "solve" the problem by pretending the input file is also cp932 when > you open it. That way you'll get the wrong characters, but no errors. So I tried that: Traceback (most recent call last): File "C:\Users\Azaz\Desktop\CK2 Map Painter\Parser\test parser.py", line 6, in text = alph

Re: [Tutor] UnicodeEncodeError: 'cp932' codec can't encode character '\xe9' in position

2012-03-10 Thread Dave Angel
On 03/10/2012 06:38 PM, Robert Sjoblom wrote: Okay, so here's a fun one. Since I'm on a japanese locale my native encoding is cp932. I was thinking of writing a parser for a bunch of text files, but I stumbled on even printing the contents due to ... something. I don't know what encoding the text

[Tutor] UnicodeEncodeError: 'cp932' codec can't encode character '\xe9' in position

2012-03-10 Thread Robert Sjoblom
Okay, so here's a fun one. Since I'm on a japanese locale my native encoding is cp932. I was thinking of writing a parser for a bunch of text files, but I stumbled on even printing the contents due to ... something. I don't know what encoding the text file uses, which isn't helping my case either (

Re: [Tutor] UnicodeEncodeError

2009-11-26 Thread Albert-Jan Roskam
/09, Kent Johnson wrote: From: Kent Johnson Subject: Re: [Tutor] UnicodeEncodeError To: "Albert-Jan Roskam" Cc: "tutor@python.org tutor@python.org tutor@python.org" Date: Wednesday, November 25, 2009, 5:55 PM On Wed, Nov 25, 2009 at 8:44 AM, Albert-Jan Roskam wrote: Hi,   I'

Re: [Tutor] UnicodeEncodeError

2009-11-25 Thread Kent Johnson
On Wed, Nov 25, 2009 at 8:44 AM, Albert-Jan Roskam wrote: > Hi, > > I'm parsing an xml file using elementtree, but it seems to get stuck on > certain non-ascii characters (for example: "ê"). I'm using Python 2.4. > Here's the relevant code fragment: > > # CODE: > for element in doc.getiterator():

Re: [Tutor] UnicodeEncodeError

2009-11-25 Thread spir
Albert-Jan Roskam wrote: > # CODE: > for element in doc.getiterator(): >   try: > m = re.match(search_text, str(element.text)) >   except UnicodeEncodeError: >     raise # I want to get rid of this exception. First, you should separate both actions done in a single statement to isolate the

[Tutor] UnicodeEncodeError

2009-11-25 Thread Albert-Jan Roskam
Hi,   I'm parsing an xml file using elementtree, but it seems to get stuck on certain non-ascii characters (for example: "ê"). I'm using Python 2.4. Here's the relevant code fragment:   # CODE: for element in doc.getiterator():   try: m = re.match(search_text, str(element.text))   except Unic

Re: [Tutor] UnicodeEncodeError

2009-07-19 Thread Mark Tolonen
"Alan Gauld" wrote in message news:h407ah$lc...@ger.gmane.org... "Mark Tolonen" wrote ... I see you are using Python 3.1. ... You can also use a shell that supports the full Unicode character set such as Idle or PythonWin instead of the console. As a matter of interest - and somewhat o

Re: [Tutor] UnicodeEncodeError

2009-07-19 Thread Alan Gauld
"Mark Tolonen" wrote ... I see you are using Python 3.1. ... You can also use a shell that supports the full Unicode character set such as Idle or PythonWin instead of the console. As a matter of interest - and somewhat off topic - does anyone know if there is a Python 3 (3.0 or 3.1) versi

Re: [Tutor] UnicodeEncodeError

2009-07-19 Thread Mark Tolonen
"gpo" wrote in message news:24554280.p...@talk.nabble.com... I'm doing a simple excercise in reading a file, and printing each line. However, I'm getting this error. The file is a windows txt file, ecoded in ANSI(ascii). I don't understand why Pythin is displaying a Unicode error. Here i

[Tutor] UnicodeEncodeError

2009-07-19 Thread gpo
I'm doing a simple excercise in reading a file, and printing each line. However, I'm getting this error. The file is a windows txt file, ecoded in ANSI(ascii). I don't understand why Pythin is displaying a Unicode error. Here is my script: f=open('I:\\PythonScripts\\statement.txt') for line

Re: [Tutor] UnicodeEncodeError

2008-10-04 Thread Kent Johnson
On Fri, Oct 3, 2008 at 4:04 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > I would try explicitly converting the data to latin-1 before you send > it to the database, giving it one of the forgiving error handling > methods I referred to earlier. Or, change your database to UTF-8... BTW to create a

Re: [Tutor] UnicodeEncodeError

2008-10-03 Thread Kent Johnson
On Fri, Oct 3, 2008 at 2:39 PM, Rob Sutherland <[EMAIL PROTECTED]> wrote: > On Fri, Oct 3, 2008 at 12:23 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > >> It helps if you show the code that is causing the error and the full >> traceback. Presumably you are calling someString.encode("some >> encoding

Re: [Tutor] UnicodeEncodeError

2008-10-03 Thread Kent Johnson
On Fri, Oct 3, 2008 at 1:50 PM, Rob Sutherland <[EMAIL PROTECTED]> wrote: > I'm working on a python application that stores email in a postgresql > database and > I'm encountering the UnicodeEncodeError - while storing a particular > email I receive > this error > > UnicodeEncodeError: 'charmap' co

[Tutor] UnicodeEncodeError

2008-10-03 Thread Rob Sutherland
I'm working on a python application that stores email in a postgresql database and I'm encountering the UnicodeEncodeError - while storing a particular email I receive this error UnicodeEncodeError: 'charmap' codec can't encode character u'\u2019' in position 144: character maps to I'm a little

Re: [Tutor] UnicodeEncodeError

2006-09-15 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi list, > > i am using site-package (webPy) that generates > "UnicodeEncodeError: 'ascii' codec can't encode characters > in position 0-6: ordinal not in range(128)". It looks like your data contains unicode strings. When you call str() on a unicode string it tries to

[Tutor] UnicodeEncodeError

2006-09-15 Thread emilia12
Hi list, i am using site-package (webPy) that generates "UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6: ordinal not in range(128)". The full message is: Traceback (most recent call last): File "c:\python24\lib\site-packages\web.py", line 1786, in run_wsgi_app res