google-code-export / django-pyodbc

Automatically exported from code.google.com/p/django-pyodbc
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xd1 #132

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I use pyodbc-azure 1.1.5 to connect my django project to a SQL Server db. My 
client is SQL Server Native Client 11.0

When I try to open the corresponging change_list I get this error:
'utf8' codec can't decode byte 0xd1 in position 4: invalid continuation byte. 
You passed in 'ESPA\xd1A' (<type 'str'>)

The annoying character is Ñ. I've checked the encoding of my db and I got that 
is Modern_Spanish_CI_AS which, I believe, is equivalent to 'latin1' or 'cp1252'.

I have tried to modify the pyodb\base.py replacing wherever utf-8 appears to 
cp1252 or latin1 (following tips described in issue 24), but the error is still 
referring to utf8.

What else can I do? (other than change the backend)

Original issue reported on code.google.com by cha...@gmail.com on 11 Apr 2014 at 7:40

GoogleCodeExporter commented 9 years ago
We can add an option in django settings setting unicode_results True, so I 
believe we don't need any patch.
I just suggest to pyodbc-azure developers to set it True by default (I don't 
see what advantage could be being False...)

Original comment by cha...@gmail.com on 11 Apr 2014 at 2:39