I'm currently working on a database that have '\0' characters in fields.
For instance the field
Category CHAR(4)
sometimes has value '\0\0\0\0' (4 zero characters) and sometimes ' ' (4 blank characters)
I want to use a script component to individuate all the fields with this problem. I've written the following script, but it doesn't work since the C# converts the '\0\0\0\0' to an empty string.
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
Type rowType = Row.GetType();
foreach (IDTSInputColumn100 column in ComponentMetaData.InputCollection[0].InputColumnCollection)
{
PropertyInfo columnValue = rowType.GetProperty(column.Name.Replace("_", ""));
Object obj = columnValue.GetValue(Row, null);
if (obj is string)
{
string s = (string)obj;
StringBuilder sb = new StringBuilder();
foreach (char c in s)
{
if (c < ' ')
{
sb.Append(' ');
}
else
sb.Append(c);
}
columnValue.SetValue(Row, sb.ToString(), null);
}
}
}
Is it possible to convert the field to a byte array instead of a string, in order to be able to individuate '\0' characters?