title: C# Script Using StreamWriter Creates Extra Character?
body: <p>I am using a C# Script Tasks in SSIS to output ASCII characters. I am doing this because I am creating a file with Packed fields, a packed field takes two digits into each byte, using a notation called Binary Coded Decimal.</p>
  
  <p>So, I have found when outputting a NUL (0x00) [Dec 0] with a Œ (0x8C) [Dec 140] it adds an extra character Â (0xC2) between them. I can't figure out why this is happening. Does anyone have any ideas? Please see my code below:</p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>Output below:</p>
  
  <p><img src="https://i.stack.imgur.com/iibqF.png" alt="ExtraCharacter"></p>
  
  <p><strong>UPDATE</strong>
  One thing I didn't make a point of is that I am passing Hex Values into the C# Script and then writing the Characters represented by the hex value to a file with fixed length columns.</p>
  
  <p>I don't know if this makes a difference, but I will also be writing other things to the file that aren't the packed values on the same lines as the packed values, and thus the reason for using the StreamWriter.  </p>