UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 9735: illegal multibyte sequence

713 views
Skip to first unread message

Hyogeun Kim

unread,
Apr 23, 2019, 8:13:35 AM4/23/19
to Django developers (Contributions to Django itself)
Hi everyone

I got this error message "UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 9735: illegal multibyte sequence" when I write some data on admin site with Django 2.2

This is simple database model like this

class Bookmark(models.Model):
url = models.URLField(max_length=500)
title = models.CharField(max_length=500)

Carlton Gibson

unread,
Apr 23, 2019, 8:27:24 AM4/23/19
to Django developers (Contributions to Django itself)
This looks to be https://code.djangoproject.com/ticket/30324, which will be fixed by 2.2.1 next week. 
(Please open a new ticket with full details if it is distinct.) 

If you set the `PYTHONIOENCODING` to utf8 before launching Python you shouldn't this. (Or related unicode errors)


HTH
Carlton 

Carlton Gibson

unread,
Apr 23, 2019, 8:30:48 AM4/23/19
to Django developers (Contributions to Django itself)


On Tuesday, 23 April 2019 14:27:24 UTC+2, Carlton Gibson wrote:
If you set the `PYTHONIOENCODING` to utf8 before launching...

Not actually sure this is sufficient. What IS the right way of setting the locale on Windows...? 

Carlton Gibson

unread,
Apr 23, 2019, 8:57:55 AM4/23/19
to Django developers (Contributions to Django itself)


On Tuesday, 23 April 2019 14:30:48 UTC+2, Carlton Gibson wrote:

What IS the right way of setting the locale on Windows...? 

Not sure if it's the only way but, on Windows 10 you can tick a "Use Unicode UTF-8 for worldwide language support", box in "Region & Language" - "Administrative" - "Change system locale" - "Region Settings".

This has a "beta" label next to it... 

After a reboot it adjusts `local.getpreferredencoding(False)` to `cp65001`, which the internets tell me is UTF8, which is what you want I think. 

C.

Hyogeun Kim

unread,
Apr 23, 2019, 8:19:32 PM4/23/19
to Django developers (Contributions to Django itself)
I think I have same problem like this https://code.djangoproject.com/ticket/30324, and I checked another Django version 1.11 and 2.1. and It works well.

thank you Carlton

PS: I tested on my Mac and I got this error message "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 9735: illegal multibyte sequence" and It works as well with version 1.11 and 2.1 on Mac

2019년 4월 23일 화요일 오후 9시 57분 55초 UTC+9, Carlton Gibson 님의 말:

Carlton Gibson

unread,
Apr 24, 2019, 2:49:07 AM4/24/19
to Django developers (Contributions to Django itself)


On Wednesday, 24 April 2019 02:19:32 UTC+2, Hyogeun Kim wrote:

PS: I tested on my Mac and I got this error message "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 9735: illegal multibyte sequence" and It works as well with version 1.11 and 2.1 on Mac

Yes. OK. It will depend on your system locale. There was an implicit assumption of something using UTF-8. Either way resolved in 2.2.1. 🙂

Please open a new ticket if something else comes up. 

Thanks! 
Carlton 
Reply all
Reply to author
Forward
0 new messages