1
votes

I am working on a fairly simple SSIS package, which reads from DB2 using ODBC Source and taking it to a flat file destination. But I need this file that is generated to be UTF-8 (without BOM) and not ANSI as it is automatically generated by SSIS. The closest thing that has worked for me is the code below, but it converts it to UTF-8 BOM and the client tells me that the file with BOM does not work for him. Is there any way I can make the file UTF-8?

string srcFilename = Dts.Variables["User::FFDestPath"].Value.ToString();
string text = File.ReadAllText(srcFilename);
File.WriteAllText(srcFilename, text, System.Text.Encoding.UTF8);
Encoding utf8WithoutBom = new UTF8Encoding(false);

Edit: enter image description here enter image description here

1
You don’t seem to be using utf8WithoutBom to actually create the file though?stuartd
@stuartd Hi, That line is for not using BOM.CXLSX
Ok, but you write the file, then you create utf8WithoutBom but you don’t use it? What do you expect it to do?stuartd
I am relatively new to C #, still learning. What do you suggest I should improve on that code to achieve what I need?CXLSX
How about File.WriteAllText(srcFilename, text, utf8WithoutBom)?stuartd

1 Answers

1
votes

For writing natively in SSIS, in your Flat File Connection manager, specify the Code Page is 65001 (UTF-8).

enter image description here

When the Flat File Destination writes a file, there is no BOM written.

enter image description here