1

I am doing

>>> s = unicode('أي كلمة من كلمات القاموس تصفك أفضل ما يمكن؟')
Unsupported characters in input

>>> s = u"أي كلمة من كلمات القاموس تصفك أفضل ما يمكن؟"
Unsupported characters in input

>>> s = "أي كلمة من كلمات القاموس تصفك أفضل ما يمكن؟".encode('utf-8')
Unsupported characters in input

>>> s = "أي كلمة من كلمات القاموس تصفك أفضل ما يمكن؟"
Unsupported characters in input

but none of them is working. what am I doing wrong?

I have django 1.6 and python 2.7

doniyor
  • 36,596
  • 57
  • 175
  • 260

1 Answers1

1

Add this line to the top of your code. It works for my Hebrew, Arabic, and technically for any other language.

#-*- coding: utf-8 -*-

Or alternatively, you can print it as a raw string. So:

s = r"أي كلمة من كلمات القاموس تصفك أفضل ما يمكن؟"
print s
GallegoDor
  • 39
  • 2
  • what is the difference between ``# -*- coding: utf-8 -*-`` and ``#!-*- coding: utf-8 -*-`` ? – doniyor Feb 27 '15 at 07:51
  • my bad you are correct there is not meant to be an exclamation point i mixed it up with the python shebang. I apologize. There is only #-\*- coding: utf-8 -*- sometimes you might see this though #-*- encoding: utf-8 -*- – GallegoDor Feb 27 '15 at 07:53