Fix Unicode issues with course ID values

Card: [CMS error, when opening a new course that have an arabic org name.](https://trello.com/c/roKoXIeH/348-cms-error-when-opening-a-new-course-that-have-an-arabic-org-name)
This PR contains the essential parts of https://github.com/edx/edx-platform/pull/5827 .