Get encoding of a file in Windows

前端 未结 12 2101
忘了有多久
忘了有多久 2020-11-22 12:16

This isn\'t really a programming question, is there a command line or Windows tool (Windows 7) to get the current encoding of a text file? Sure I can write a little C# app b

12条回答
  •  旧时难觅i
    2020-11-22 12:42

    The (Linux) command-line tool 'file' is available on Windows via GnuWin32:

    http://gnuwin32.sourceforge.net/packages/file.htm

    If you have git installed, it's located in C:\Program Files\git\usr\bin.

    Example:

        C:\Users\SH\Downloads\SquareRoot>file *
        _UpgradeReport_Files;         directory
        Debug;                        directory
        duration.h;                   ASCII C++ program text, with CRLF line terminators
        ipch;                         directory
        main.cpp;                     ASCII C program text, with CRLF line terminators
        Precision.txt;                ASCII text, with CRLF line terminators
        Release;                      directory
        Speed.txt;                    ASCII text, with CRLF line terminators
        SquareRoot.sdf;               data
        SquareRoot.sln;               UTF-8 Unicode (with BOM) text, with CRLF line terminators
        SquareRoot.sln.docstates.suo; PCX ver. 2.5 image data
        SquareRoot.suo;               CDF V2 Document, corrupt: Cannot read summary info
        SquareRoot.vcproj;            XML  document text
        SquareRoot.vcxproj;           XML document text
        SquareRoot.vcxproj.filters;   XML document text
        SquareRoot.vcxproj.user;      XML document text
        squarerootmethods.h;          ASCII C program text, with CRLF line terminators
        UpgradeLog.XML;               XML  document text
    
        C:\Users\SH\Downloads\SquareRoot>file --mime-encoding *
        _UpgradeReport_Files;         binary
        Debug;                        binary
        duration.h;                   us-ascii
        ipch;                         binary
        main.cpp;                     us-ascii
        Precision.txt;                us-ascii
        Release;                      binary
        Speed.txt;                    us-ascii
        SquareRoot.sdf;               binary
        SquareRoot.sln;               utf-8
        SquareRoot.sln.docstates.suo; binary
        SquareRoot.suo;               CDF V2 Document, corrupt: Cannot read summary infobinary
        SquareRoot.vcproj;            us-ascii
        SquareRoot.vcxproj;           utf-8
        SquareRoot.vcxproj.filters;   utf-8
        SquareRoot.vcxproj.user;      utf-8
        squarerootmethods.h;          us-ascii
        UpgradeLog.XML;               us-ascii
    

提交回复
热议问题