file - codecs - unicode ???

Sébastien Libert sebastien.libert at comexis.com
Wed Mar 14 03:09:52 EST 2001


Hello,

Big thaks for your help !!!!!!!!!

Now i have found a  sulotion that work nice ( for me ! ).
If this solution can help - use it !

import codecs

def ConvertUTF16ToLATIN1(inputFile,outputFile)
    """
        ConvertUTF16ToLATIN1 : convert UTF-16 file in LATIN-1 file

        Parameters :
            inputFile : file in UTF-16 format
            outputFile : file in LATIN-1 format generated from the inputFile

    """

    f=codecs.open(inputFile,'rb','utf-16')
    g=open(outputFile,'w')

    ffile=f.read()
    ffile.encode('latin-1')
    g.write(ffile)

    f.close
    g.close


"Sébastien Libert" <sebastien.libert at comexis.com> wrote in message
news:3aace9da$0$382$446d705c at news.skynet.be...
> Hi,
>
> here is a sample of what i do :
>
> >>> h=open("c:\\myfile.log")
> >>> line=h.readline()
> >>> line
>
'\377\3760\000.\0000\0000\000\011\000i\000n\000f\000o\000\011\000L\000o\000g
>
\000_\000S\000t\000a\000n\000d\000a\000r\000d\000\011\000n\000g\000L\000o\00
> 0g\000\015\000\012'
>
> What can i do with this kind of thing ?????
> I want to convert thid in ascii.... how can i do thid in python ?
>
> I use python 2.0 on win32 !!!
>
> thx to answerd ;-)
>
>





More information about the Python-list mailing list