Question


I've read similar posts on this and they don't answer my question.

Similar post I found is : how to pass parameters to tortoiseproc.exe via file?


but the problem is unresolved and stuck on creation of file with UTF-16 encoding without BOM.

I'm trying to automate commits for my project using tortoisesvn command

TortoiseProc.exe /command:commit /pathfile:"D:\p3.tmp" /logmsg:"test log message" /deletepathfile

where "D:\p3.tmp" file contains list of files that must be commited.

This file shuld be with UTF-16 encoding without BOM.

C# Code that I use to create a file:

string line = @"D:\SourceCode\ProductProvider.cs";           
    using (var s = File.Create("D:\\p3.tmp"))
    {
     using (var sw = new StreamWriter(s, new UTF32Encoding()))
     {
         sw.WriteLine(line);
     }
    }
Was it helpful?

Solution

You'll want to use a non default constructor of the UnicodeEncoding class to create an UTF16 encoding without a BOM;

using (var sw = new StreamWriter(s, new UnicodeEncoding(false, false)))
{
    sw.WriteLine(line);
}

The first false sets little endian encoding, you can set it to true for big endian. The second false disables the BOM.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top