Add codepage auto detection

When a file is opened, the codepage is automatically detected
and converted.