return ''
new = ''
for i in range(int(len(h) / 4)):
new += chr(int(h[i * 4:(i + 1) * 4], 16))
return new.encode('utf-16', 'surrogatepass').decode('utf-16')
def unicode_to_hex(t):
if not t:
return ''
return ''.join(['{:04x}'.format(ord(x)) for x in t])
def validate_phone(phone):
try:
phone = phonenumbers.parse(phone)
if phonenumbers.is_valid_number(phone):
return '+%s%s' % (phone.country_code, phone.national_number)
else:
return False
except phonenumbers.NumberParseException:
return False