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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -