1

I am getting this error in Django:

 UnicodeDecodeError at /category/list/ 'utf8' codec can't decode byte 0xf5 in position 7: invalid start byte Request Method: GET Request URL: ... Django Version: 1.3.1 Exception Type: UnicodeDecodeError Exception Value: 'utf8' codec can't decode byte 0xf5 in position 7: invalid start byte Exception Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py in iterencode, line 264 ... 

I should save Turkish characters in the database. How can I fix this error?

3 Answers 3

4

A start-byte of 0xf5 would indicate the start of a 4-character UTF-8 encoding. One strong possibility is that the input isn't UTF-8 at all but ISO-8859-9, the Turkish ISO encoding. On that codepage 0xf5 is a lowercase o with tilde or õ.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes it is an ö. So I should be careful on saving the strings, or getting the strings from the DB? Also I am using django-trans for translations. Can it be the problem?
1

Below code solved my problem. Thank you.

if isinstance(encObject, unicode): myStr = encObject.encode('utf-8') 

Comments

0

http://www.fileformat.info/info/unicode/char/f5/index.htm

it is an o with a tilde

try

some_string.decode('latin1','replace') 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.