File: guessencoding.py

package info (click to toggle)
isomaster 1.3.13-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, stretch
  • size: 2,872 kB
  • ctags: 826
  • sloc: ansic: 11,238; makefile: 172; sh: 99; python: 11
file content (17 lines) | stat: -rwxr-xr-x 347 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/python

import locale

FILENAME = "pt.po"
ENCODING = "UTF-8"

if __name__ == "__main__":
    
    data = open(FILENAME, 'rb').read()
    
    try:
        unicode(data, ENCODING)
    except:
        print "wrong encoding (" + ENCODING + ") or something"
    else:
        print "encoding " + ENCODING + " seemed to work on " + FILENAME