I'm trying to search for a special character using the CMD command:
findstr /s /i <special_character> *.*
The character I want to search for is …
That is, three dots all compressed into a single character.
How can I do this?
If the character encoding of the text file is Microsoft Windows proprietary codepage 1252 (English and Western Europe), then you can use FINDSTR.EXE
.
The ellipsis in codepage 1252 is at 0x85. To enter the character at the command line using codepage 437, you would hold down the Alt key while entering the decimal value of 0x85. That decimal value is 133.
Enter the following text into Notepad by either copy and paste or holding down the Alt key while entering on the numeric keypad 0133. Save this as myscript.bat
.
findstr /L "…" myfile.txt
From a cmd
shell, enter TYPE myscript.bat
. It will appear as shown below. This is because 133 in codepage 1252 is the HORIZONTAL ELLIPSIS character, but in codepage 437 it is a LATIN SMALL LETTER A WITH GRAVE.
findstr /L "à" myfile.txt
Use the chcp
command to see the codepage currently used in the cmd
shell.
When myscript.bat
is run from the cmd
shell, the character at codepoint 0x85 will appear as LATIN SMALL LETTER A WITH GRAVE because it is in codepage 437.