Converting DOS text files to Unicode using Python -
i trying write python application converting old dos code page text files unicode equivalent. now, have done before using turbo pascal creating look-up table , i'm sure same can done using python dictionary. question is: how index dictionary find character want convert , send equivalent unicode unicode output file?
i realize may repeat of similar question nothing searched here quite matches question.
python has codecs conversions:
#!python3 # test file bytes 0-255. open('dos.txt','wb') f: f.write(bytes(range(256))) # read file , decode using code page 437 (dos oem-us). # write file utf-8 encoding ("unicode" not encoding) # utf-8, utf-16, utf-32 encodings support unicode codepoints. open('dos.txt',encoding='cp437') infile: open('unicode.txt','w',encoding='utf8') outfile: outfile.write(infile.read())
Comments
Post a Comment