Read the first unit from a po file without decoding the characters;
that is, everything is read into a Python str type. Then check to
see if there is a header; if there is, then try to determine the
file encoding from that and set the file encoding. Otherwise, leave
the file encoding at the default (UTF-8).
Then, decode the file contents and restart the parsing.
Originally, the parser would assume a UTF-8 encoding until it hit
a Content-Type declaration which specified the file encoding. Only
then would it change the decoding scheme.
This worked fine for non-UTF-8 files which contained only ASCII
characters in the header (which appeared before the Content-Type
declaration), but raised an exception if any non-ASCII characters
appeared there, since a UTF decoding error occured.
This patch both simplifies the original code and fixed this bug.
git-svn-id: http://translate.svn.sourceforge.net/svnroot/translate/src/trunk/translate@7519 54714841-351b-0410-a198-e36a94b762f5