I am trying to convert Arabic text to utf8
encoded bytes then to binary by using this answer here.
First, I used the code as it is in the example:
'{:b}'.format(int(u'سلام'.encode('utf-8').encode('hex'), 16))
But I got this error:
AttributeError: 'bytes' object has no attribute 'encode'
Also I removed .encode('hex')
but still gives the same error.
Is there any way to convert utf8
codes to binary and vise versa?