Roger Johansson
Roger Johansson

Reputation: 23224

Process.Start batch-file and encoding

I'm having a bit of problem with processing bat/batch files from .NET. I do Process.Start and I can start the actual file, however, if the bat file is encoded with UTF8, it gets incorrectly decoded since DOS uses some other encoding.

Can I start the process with a different encoding and would that affect the encoding of the actual bat file?

The bat file is inclided as a Copy Always resource in the project and I'm not completely comfortable saving it using DOS encoding and checking it into TFS and distribute it to all team members, pretty certain that this will blow up eventually..

Upvotes: 1

Views: 654

Answers (1)

Pavel Krymets
Pavel Krymets

Reputation: 6293

UTF should be perfectly normal, i think the problem is BOM (byte order mark) in the beginning of the file. To get rid of it:

Select save as and extend the save button in file dialog and select "Save with encoding". Or if you you want to get rid of this setting permanently just open File menu and select "Advanced save options" and there you should select "UTF-8 without signature" (and that also answered your last question :). Yes "UTF-8 without signature" is same as without BOM. (UTF-8 without BOM)

Upvotes: 1

Related Questions