I am using C # Script Tasks in SSIS to output ASCII characters. I do this because I create a file with Packed fields, a packed field takes two digits per byte using the Binary Coded Decimal notation.
So, I found that when outputting NUL (0x00) [Dec 0] with Ε (0x8C) [Dec 140], it adds an extra character Γ (0xC2) between them. I canβt understand why this is happening. Does anyone have any ideas? See my code below:
string fileName; System.IO.StreamWriter writer; public override void PreExecute() { base.PreExecute(); this.fileName = this.Variables.FilePath; } public override void PostExecute() { base.PostExecute(); writer.Flush(); writer.Close(); } public override void Input0_ProcessInputRow(Input0Buffer Row) { writer.Write((char)00); writer.Write((char)140); writer.Write((char)13); writer.Write((char)10); }
The result is below:

UPDATE The only thing I did not talk about is that I pass Hex Values ββto C # Script, and then write the characters represented by the hexadecimal value into a file with fixed-length columns.
I don't know if this matters, but I will also write other things to the file that are not packed values ββon the same lines as packed values, and therefore the reason for using StreamWriter.
source share