Binary or ascii file?
quinn at ngwee.ugcs.caltech.edu
Fri Sep 8 12:25:09 CEST 2000
On Thu, 07 Sep 2000 17:58:35 +0200, Anders M Eriksson
<anders.eriksson at morateknikutveckling.se> wrote:
>Working on windows I need to know if the file I'm about to open is
>binary or ascii.
>How can I find out which the file is?
As far as I know, there is no way to know for sure, under unix or windows (or
any os, even macos when creator isn't set). Programs that want to figure it
out usually look for non-printable characters, and if there's a significant
number of them, assume it's binary. This works pretty well, but can get
confused when the locale of the text file you're reading has a different idea
of what 'non-printable' is.
More information about the Python-list