File.Replace task and Encoding

May 7, 2008 at 6:38 PM
In trying to modify the version number of a C++ project during each build, I used the File.Replace task on my .rc file. I set the TextEncoding parameter of the task to "windows-1250", but it was still changing the copyright symbol into a question mark, despite that symbol not being part of the text I was changing. A little digging showed that you're only using the passed encoding when you write the file, but using the default encoding to read the file into a string. I copied the task into my own project, changed it to use the passed encoding on the StreamReader as well as the StreamWriter, and now it works for me. I'd be happy to send in my changes if you'd like.

Great library!
Developer
May 8, 2008 at 6:57 AM
Hi Marc

Would appreciate the contribution.

Thanks

Mike
May 8, 2008 at 7:18 PM
OK, after some fiddling (this is my first contribution to CodePlex), I got the project to build and uploaded the patch. I couldn't run any tests, since I only have VS2005 Pro, and I've only tested it with my ascii file. I don't know what the expected standard for submitted patches is, but this one is of the "works for me, I hope it might help somebody else out" variety.

-Marc
Developer
May 9, 2008 at 7:23 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Developer
May 9, 2008 at 8:04 AM
Thanks Marc. Checked in and will be in the next release...