1.

Solve : How to use the "find" command with extended ASCII characters ??

Answer»

Hi everyone,

I am currently trying to use the "find" command with extended ASCII characters, such as "é" but I can't make it. The solution may be quite simple but I am not an expert of DOS.

For academic purposes, I am trying to use DOS to find specific strings in a huge .txt file and export the results into a new .txt file. The first problem I encountered was I couldn't find extended ASCII characters at all. But then I understood it must be a encoding problem, so I converted this huge file from ANSI to "UCS-2 Litte Endian", the only one that works correctly. With the file being in UCS-2 Little Endian, DOS does find extended ASCII characters. If I don't specify an output file, then DOS displays the result list and this list IS correct. But what I need, of course, is to save the results in a new file, so I specify it in the command line. Here is an example of what I type (say I am looking for "é" in the a.txt file):

find "é" d:\a.txt > d:\results.txt

The problem is that extended ASCII characters are not preserved in the results.txt file. For example, instead of getting "fiancé" I get "fianc,". So I guess it is an encoding problem because it seems that I can't get 128+ ASCII characters in the output file whereas I do get them directly on my SCREEN if I don't ask for an output file.

Could you HELP me preserve the extended ASCII characters in the output file ? I really don't know how to do ...

I hope you can understand my problem correctly; I'm not USED to using computer-related terms in English (I'm French) so I may not be using the right ones.

Thanks a lot in advance !

Jérémy


edit: I'm realising that it's not really related to the find command. To put it more simply, if I type "echo fiancé > d:\test.txt" then the test.txt file does not contain "fiancé" but "fianc,". How can I do ? Thanks !What code PAGE are you using? Type chcp (without any parameters) to see which one you are using

I think maybe you need to set your console code page to 1252:

chcp 1252

or try

chcp 863







Hi,

I'm using code 850.

I tried the ones you mentioned but it doesn't change anything.
But I'm not sure my message really was clear. If I type "echo é" I do get "é" correctly. The problem is only if I want an output file, that is, if I type "echo é > d:\test.txt". In this case, test.txt does not contain "é" but ",".
I take the example of "é" but it's not restricted to letters with accents, I get the same problem with all 128+ ascii characters.Strange.

Code: [SELECT]
C:\>chcp

C:\>Active code page: 863

C:\>echo maquillé comme mon fiancé>indochine.txt

C:\>type indochine.txt
maquillé comme mon fiancé

I do get the same thing as you but only if I use the "type" command. If I go fetch the file and open it manually then I get "," instead of "é". What about you ? Have you tried opening the file manually (not via DOS but via Windows) ?



Discussion

No Comment Found