MQ Txn that has a little 22 in the top left corner

We are in the process of testing a program that creates MQ txns using VB2010.
Notice the teeny little 22 in the top left corner?  What is that?  Does it have something to do with how we are using the Encoding.UTF8 method?  The receiver of this txn able to read and process it, so it doesn't cause any harm, but I would love to know what it is (and if I should not have it in there).
Thank you for helping me!

²²<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<StuffHere>
  <Address>xxx</Address>
  <Agency>xx</Agency>
  <ArriveDate>10/01/2013 10:57:12 AM</ArriveDate>
</StuffHere>

Open in new window


Here is the initial definition:
xmlDoc = New XmlDocument
            Dim xmlDec As XmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "yes")

Open in new window


And here is how we write it out after filling the data:
xml = Encoding.UTF8.GetString(xmlMem.GetBuffer, 1, Convert.ToInt32(xmlWriter.BaseStream.Position - 1))

Open in new window

ToolTimeGangAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
That looks like the Byte Order Marker (BOM).

What is "xmlMem" defined as?
0
Bob LearnedCommented:
Oh, and the UTF8Encoding class has overloaded constructors with a version that allows you to control whether to write the BOM, but I can't see how that would fit this situation.

UTF8Encoding Constructor (Boolean)
http://msdn.microsoft.com/en-us/library/s064f8w2.aspx

encoderShouldEmitUTF8Identifier
Type: System.Boolean
true to specify that a Unicode byte order mark is provided; otherwise, false.
0
ToolTimeGangAuthor Commented:
Answer to your first question:
Dim xmlMem As New MemoryStream(10 * 1024)

If this is a BOM, it looks like it won't hurt anything by being there.  How can I be sure that is what it truly is?
0
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Bob LearnedCommented:
If you would like to verify the byte order mark, then you could use a hex editor, and verify those bytes.

Reference:

The byte-order mark (BOM) in HTML
http://www.w3.org/International/questions/qa-byte-order-mark

For example, in editors such as Notepad++ on Windows and TextWrangler on the Mac, it is possible to select the encoding from a list while using the Save As function. The list has options to save as UTF-8 with or without the BOM. Just choose the option without the BOM and save.
0
ToolTimeGangAuthor Commented:
According to http://www.w3.org/International/questions/qa-byte-order-mark, this txn does NOT have a BOM.
But it also says this:
Due to the lack of HTTP headers some checks have not been run. Specifically charset and language declaration consistencies were not checked against the missing 'Content-Type' and 'Content-Language' headers respectively.
0
Bob LearnedCommented:
What is the byte sequence before the XML declaration element?
0
ToolTimeGangAuthor Commented:
I am not sure I understand your question.  Do you mean what comes before this line?
²²<?xml version="1.0" encoding="utf-8" standalone="yes"?>

Open in new window

0
Bob LearnedCommented:
If you open the file with a hex editor, you should see the byte values for those characters.  This should be the bytes for the Unicode characters that you are seeing.
0
ToolTimeGangAuthor Commented:
Neato.  I see it now. Hex value for the 22 is B2 B2.  So is that a BOM then?

BTW...I just learned that we are no longer getting this little 22.  We removed some logic.  And I think this is what was making that 22 show up:

 Dim xmlMem As New MemoryStream(10 * 1024)
            xmlWriter = New XmlTextWriter(xmlMem, Encoding.UTF8)

Open in new window


We also replaced this:
 xmlDoc = New XmlDocument
            Dim xmlDec As XmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "yes")

Open in new window


With this:
xmlDoc = New XmlDocument

Open in new window


Make sense?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob LearnedCommented:
Hmmm....B2 B2 doesn't correspond to anything that I know of BOM, but your evidence suggests the presence of one.

http://en.wikipedia.org/wiki/Byte_order_mark

The UTF-8 representation of the BOM is the byte sequence 0xEF,0xBB,0xBF.  A text editor or web browser interpreting the text as ISO-8859-1 or CP1252 will display the characters  for this.
0
ToolTimeGangAuthor Commented:
Well, I think I am going to put this issue to rest then.  Thank you so  much once again for your continued help and support oh Learned One!  You have helped me in the past and I look forward to future help as well!  Thank you!
0
ToolTimeGangAuthor Commented:
I didn't know about BOM until this entry.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.