I have searched many times online and I have not been able to find a way to convert my binary string variable, X
X = "1000100100010110001101000001101010110011001010100"
into a UTF-8 string value.
I have found that some people are using methods such as
b'message'.decode('utf-8')
however, this method has not worked for me, as 'b' is said to be nonexistent, and I am not sure how to replace the 'message' with a variable. Not only, but I have not been able to comprehend how this method works. Is there a better alternative?
So how could I convert a binary string into a text string?
EDIT: I also do not mind ASCII decoding
CLARIFICATION: Here is specifically what I would like to happen.
def binaryToText(z):
# Some code to convert binary to text
return (something here);
X="0110100001101001"
print binaryToText(X)
This would then yield the string...
hi