Forum Home
Press F1
 
Thread ID: 111449 2010-07-27 10:08:00 .txt and .bat file encoding clashes. Problem. dotbond (7154) Press F1
Post ID Timestamp Content User
1122902 2010-07-27 10:08:00 Hi. I have an installation log file saved as a .txt file from installing MS Dynamics CRM for Outlook. I am trying to parse it with a .bat file, looking for a particular string.
The problem seems to be that the generated .txt file is encoded in UCS-2 Little Endian and the .bat file is encoded in ANSI. The bat file cannot read the txt file.
I have tried saving the bat file in the same encoding spec as the txt file but then the bat file does not work.
I need to parse the txt file in real time looking for the string to say that the install was successful, basically

Anyone come across this problem, or a similar problem?

Thanks
Trev
dotbond (7154)
1122903 2010-07-27 10:31:00 Don't reinvent the wheel just download WinGrep. (http://www.wingrep.com/) mikebartnz (21)
1122904 2010-07-27 11:30:00 Thanks for the reply. I have had a look at the program suggested but I need a batch file, or something similar, as the batch file is to be deployed to networked computers to determine which version of Windows they are running and then start a silent install of Dynamics CRM using switches and then updates then configuring the program via an XML config file. So it's doing more than just finding a string.

Trev
dotbond (7154)
1122905 2010-07-27 11:50:00 Have you looked at Microsoft's PowerShell, or maybe just Python or Perl? I would have thought that any of these modern languages could handle UCS-2.

Does the .txt file have special prefix bytes at the start of the file? I'm sure there's some standard codes stored as the first couple of bytes which specify the encoding used in the file. Does Notepad open the .txt file correctly? I think it should if the encoding bytes are present.
MushHead (10626)
1122906 2010-07-27 12:11:00 Thanks for the reply. I have had a look at the program suggested but I need a batch file, or something similar, as the batch file is to be deployed to networked computers to determine which version of Windows they are running and then start a silent install of Dynamics CRM using switches and then updates then configuring the program via an XML config file. So it's doing more than just finding a string.

Trev
I didn't have a thorough look at the site but it has a command line version as well with a replace function. I haven't used it for years as I no longer use Windows.
mikebartnz (21)
1122907 2010-07-27 22:31:00 No I haven't looked at Powershell or Perl. May have to if time allows.

I have been opening up the files using Notepad++ and that was telling me the encoding format. There aren't any prefix bytes at the start of the file that I can see.
Yes Notepad and Notepad++ both open the files correctly and I can read them.
dotbond (7154)
1