Reputation: 55
I'm trying to read a file and send the data to a socket. But I can't convert a ÿ character to a single byte.
Not if I read a file or use a string and convert it. I think the problem is the coding of the file but I can't seem to find the correct one. For this example I will only show the string conversion.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import binascii
s = "ÿ"
b = bytearray(s)
print binascii.hexlify(b)
>>result: c3bf
so the ÿ character is stored as 2 bytes. But I want to convert it to a single bytes that's 0xFF.
thanks in advance
Upvotes: 0
Views: 1784