encoding latin1 to utf-8

Harshad Modi modiinfo at gmail.com
Mon Sep 10 08:25:46 EDT 2007


hello ,
 I make one function for encoding latin1 to utf-8. but i think it is
not work proper.
plz guide me.

it is not get proper result . such that i got "Belgi�" using this
method, (Belgium)  :

import codecs
import sys
# Encoding / decoding functions
def encode(filename):
 file = codecs.open(filename, encoding="latin-1")
 data = file.read()
 file = codecs.open(filename,"wb", encoding="utf-8")
 file.write(data)

file_name=sys.argv[1]
encode(file_name)




More information about the Python-list mailing list