If text file has utf-8 signature (BOM), we want to remove that without using disassambler, I used the following code
byte[] buffer = new byte[streamLength];//new byte[originalStrm.Length];
originalStrm.Read(buffer, 0, Convert.ToInt32(streamLength));
byte[] preamble = Encoding.UTF8.GetPreamble();
//239 187 191
if (preamble[0] == buffer[0] && preamble[1] == buffer[1] && preamble[2] == buffer[2])
{
System.Diagnostics.Trace.WriteLine(" file has utf-8 signature and removed ");
byte[] bufferN = new byte[streamLength-3];//new
Buffer.BlockCopy(buffer, 3, buffer, 0, streamLength - 3);
buffer = bufferN;
}
else
System.Diagnostics.Trace.WriteLine(" file does not have utf-8 signature");
This site is used to publish and share my articles, my experiences and knowledge about Business Applications Automation / Integration through biztalk, tibco,seebeyond, bpm, automation/intergration tools)
Subscribe to:
Post Comments (Atom)
test
-
We have three fields as address1, address2 and address3 in source schema and in destination side; we want to concatenate them with new line ...
-
Combining / Merging multiple repeated records from source into single record in destination with conditional through Biztalk map 1. Sour...
-
Business automation is nothing but it enables to automate enterprise business processes, services and applications across enterprise as we...
2 comments:
I never know that BOM is a part of file and we need to remove that for UTF-8 format. After reading this article, now I know how to remove BOM indicator for passthrough data / files.
you have made a mistake in the the BockCopy command, source is the same as target
Post a Comment