UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

akhil1988 akhilanger at gmail.com
Sat Jul 18 14:20:20 EDT 2009


Thanks Nobody-38, it solved my problem immediately.

--Thanks Again,
Akhil

Nobody-38 wrote:
> 
> On Thu, 16 Jul 2009 20:26:39 -0700, akhil1988 wrote:
> 
>> Well, you were write: unintentionally I removed strip(). But the problem
>> does
>> not ends here:
>> 
>> I get this error now:
>> 
>>  File "./temp.py", line 488, in <module>
>>     main()
>>   File "./temp.py", line 475, in main
>>     for line in sys.stdin:
>>   File "/usr/local/lib/python3.1/codecs.py", line 300, in decode
>>     (result, consumed) = self._buffer_decode(data, self.errors, final)
>> UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-2:
>> invalid
>> data
>> 
>> for this line:
>> â
> 
> Right. You're running in a locale whose encoding is UTF-8, but feeding
> data which isn't valid UTF-8 to stdin. If you want to use data with a
> different encoding, you need to replace sys.stdin, e.g.:
> 
> import sys
> import io
> sys.stdin = io.TextIOWrapper(sys.stdin.detach(), encoding = 'iso-8859-1')
> 
> -- 
> 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-tp24509879p24550497.html
Sent from the Python - python-list mailing list archive at Nabble.com.




More information about the Python-list mailing list