Re: Django on legacy Postgres database with encoding WIN1252

160 views
Skip to first unread message

Ian Clelland

unread,
Oct 4, 2012, 1:48:30 PM10/4/12
to django...@googlegroups.com
What is that character supposed to be?

According to the Wikipedia page on CP1252, 0x81 is an unused character position. There is a mention that it might map to some ISO-2022 control code with no unicode equivalent.

I'm not sure where the error message is coming from, though -- if it was in the python layer, you would see something like:

    UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 0: character maps to <undefined>

Possibly the postgresql interface is trying to convert it to UTF8 for transfer, and failing, or maybe the psycopg2 layer can't decode it. Is there any other info you can provide about the error message?

It may end up that you just have to clean the data in the database to be able to use it.

Ian

On Thu, Oct 4, 2012 at 9:57 AM, Janeskil1525 <janesk...@gmail.com> wrote:
Hi all

I'm new Django user. I have a legacy system based on a Postgres 9.1 database that is using encoding WIN1252. When i try to retrie data from one table I get the following error

>>character 0x81 of encoding "WIN1252" has no equivalent in "UTF8"<< , does that mean i cant use Django together with this database or is there some setting i need to change ?

All help appreciated

Thank you in advance!


Jan Eskilsson

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/EXpvuuttJ64J.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



--
Regards,
Ian Clelland
<clel...@gmail.com>

Janeskil1525

unread,
Oct 5, 2012, 2:14:57 PM10/5/12
to django...@googlegroups.com
Hi Ian


Thank you for your response.

It turns out that the problem is not Django related at all, the Legacy system adds this character 0x81 of some reason to text strings and it seems like its the Postgres driver that fails to convert this to a UTF8 char. So its true, i have to purge the data somehow before its read.


Jan
Reply all
Reply to author
Forward
0 new messages