5

I have a file which may be in ASCII or UTF-8 format. I can know which format it is through Notepad++. But can some one tel me a tool that could show me in which format the file is through command prompt.

Example: Open Command Prompt,

C:><Some Command> FileName

which should give me the file format like ASCII or UTF-8.

Amarnath
  • 8,736
  • 10
  • 54
  • 81
  • 1
    Possible duplicate of [How to check if a .txt file is in ASCII or UTF-8 format in Windows environment?](http://stackoverflow.com/questions/6947749/how-to-check-if-a-txt-file-is-in-ascii-or-utf-8-format-in-windows-environment) – krystan honour Nov 11 '16 at 11:05

2 Answers2

-1
  1. Install Python 3.x
  2. Run command in cmd.exe (Administrator): pip install chardet
  3. Write a small python script that read a file, detect the encoding, and print the encoding using the newly installed module chardet. See here for help.
  4. Put the script somewhere under PATH

Suppose you create ec.py doing the job. Then you can invoke ec FileName on command line to get the encoding. If you do a good job writing the python script, you can invoke something like ec *.txt to get the encodings of multiple files.

Kevin
  • 143
  • 1
  • 7
-3

This is a duplicate of this question here which has a great answer (not by me I might add)

EDIT

I am pretty sure there is not way that is reliable to do this, usually you are told the encoding of a file, sure you can look for a Byte Order Mark (BOM) at the start of the file but its not mandatory and so is not a true indicator unless you know for SURE its supposed to be there.

Unless someone knows differently I don't think its possible to work out from scratch you have to have some clue about the encoding used.

Community
  • 1
  • 1
krystan honour
  • 6,523
  • 3
  • 36
  • 63
  • 1
    I think the chcp is not for what I am looking for. Because what I was expecting is "whether there is a tool that will take a file as input and print in the file format." Example: Say we have a tool by name "TOOL." If I give in command prompt like "TOOL file.txt" then output should be either ASCII or UTF or someother format. – Amarnath Mar 27 '12 at 16:46
  • please clarify what you mean by print, do you mean output to the console or print on an actual printer – krystan honour Mar 27 '12 at 18:40