I am encoding strings with p.encode('utf-8')
into utf-8
.
I than trying to catch what might have gone wrong with
def assert_encoding(s):
try:
if s is None or pd.isnull(s) or (not isinstance(s, basestring)) or s.decode('utf-8') :
return True
except UnicodeError:
return False
A string goes through an assert(encoding(s))
but then an INSERT INTO
my Postfres database (configured for UTF-8
) fails with the error saying that 0xC3 0x20
is not an UTF-8 supported byte sequence.
- Is there a loop-hole in assert_encoding?