text_utf16 = text.encode('utf-16-le')
for entity in entities:
    start = entity['offset']
end = start + entity['length']
entity_text = text_utf16[start * 2:end * 2].decode('utf-16-le')
print(('Url: ', entity_text))
UTF-16 codepoint counting in python