A
Arifi Koseoglu
Hello everyone.
I am an absolute Newbie who has done a good amount of googling with
the keywords utf-8, utf-16, python, convert and has reasoned that the
following code could be used to convert a utf-8 text file to a
utf-16-le (I believe this is what Windows uses for Unicode):
s1 = open("utf8_file_generated_with_perl.txt", "r").read()
s2 = unicode(s1, "utf-8")
s3 = s2.encode("utf-16-le")
open ("new_file_supposedly_in_utf16le", "w").write(s3)
Well, this code kind of works (meaning I do not get any errors), but
the produced file contains an extra space after every character (l i k
e t h i s) and Windows believes this is an ANSI (i.e. non-unicode
file). Clearly, what I think is working is actually not.
What do I need to do?
Many thanks in advance,
-arifi
I am an absolute Newbie who has done a good amount of googling with
the keywords utf-8, utf-16, python, convert and has reasoned that the
following code could be used to convert a utf-8 text file to a
utf-16-le (I believe this is what Windows uses for Unicode):
s1 = open("utf8_file_generated_with_perl.txt", "r").read()
s2 = unicode(s1, "utf-8")
s3 = s2.encode("utf-16-le")
open ("new_file_supposedly_in_utf16le", "w").write(s3)
Well, this code kind of works (meaning I do not get any errors), but
the produced file contains an extra space after every character (l i k
e t h i s) and Windows believes this is an ANSI (i.e. non-unicode
file). Clearly, what I think is working is actually not.
What do I need to do?
Many thanks in advance,
-arifi