[Tutor] unicode to plain text conversion

Kent Johnson kent37 at tds.net
Tue Apr 7 17:52:32 CEST 2009


On Tue, Apr 7, 2009 at 10:44 AM, Pirritano, Matthew
<MPirritano at ochca.com> wrote:

> How can I find out the type of coding that was used to create this file?
> Is there a way to do this other than just asking the person who created
> it? That is possible, but I was just curious.

If you can look at the data as hex values it's pretty easy to
distinguish utf-8, utf-16be and utf-16le, which are the most likely
codings. In Python you could try

f = open('unicode_file.txt')
s = f.read(20)
print repr(s)

Kent


More information about the Tutor mailing list