UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)
akhil1988
akhilanger at gmail.com
Thu Jul 16 01:09:38 EDT 2009
Sorry, it is sgmllib.py and not sgmmlib.py
-- Akhil
akhil1988 wrote:
>
> Well,
> All I get is this traceback:
>
> File "./customWikiExtractor.py", line 492, in ?
> main()
> File "./customWikiExtractor.py", line 480, in main
> print >> sys.stdout, 'line: %s' % line
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in
> position 13: ordinal not in range(128)
>
> I am giving a string to the python code as input, and python processes it
> like this:
>
> line = line.decode('utf-8').strip()
>
> After this when I do,
> print >> sys.stdout, 'line: %s' % line
> I get this Unicode error.
>
> I tried a few repairs, but they did not work like
> changing: in sgmmlib.py (/usr/lib64/python2.4/sgmmlib.py)
> if not 0 < n <= 255
> to
> if not 0 < n <= 127
>
> But since this did not work, I have changed it back to it's original form.
>
> --Thanks,
> Akhil
>
>
> Chris Rebert-6 wrote:
>>
>> On Wed, Jul 15, 2009 at 9:34 PM, akhil1988<akhilanger at gmail.com> wrote:
>>>
>>> Hi!
>>>
>>> Can anyone please help me getting rid of this error:
>>> UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in
>>> position
>>> 13: ordinal not in range(128)
>>>
>>> I am not a python programmer (though intend to start learning this
>>> wonderful
>>> language), I am just using a python script.
>>>
>>> After doing some search, I found that 0xb7 is a 'middle dot character'
>>> that
>>> is not interpreted by the python.
>>> Even after inserting text = text.replace('\u00b7', '') in the script,
>>> the
>>> problem still persists.
>>>
>>> Can anyone please tell me the easiest way to get rid of this?
>>
>> We'll need the full error traceback. The error message at the end is
>> just not enough information.
>> As to fixing it, google for "UnicodeEncodeError". You should find
>> about a million mailinglist threads on it.
>>
>> Cheers,
>> Chris
>> --
>> http://blog.rebertia.com
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>>
>
>
--
View this message in context: http://www.nabble.com/UnicodeEncodeError%3A-%27ascii%27-codec-can%27t-encode-character-u%27%5Cxb7%27-in-position-13%3A-ordinal-not-in-range%28128%29-tp24509879p24510252.html
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list
mailing list