473,480 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Get 3 chars before <?xml version...

Hi;

My code is:

XmlDocument doc = new XmlDocument();
doc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", ""));
....
doc.Save(outStream);

And my saved document has:
0xef 0xbb 0xbf before the <?xml...

What do I have to do to eliminate this? (.net 2.0)

--
thanks - dave
Nov 12 '05 #1
5 1125
Hello!
XmlDocument doc = new XmlDocument();
doc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", ""));
...
doc.Save(outStream);

And my saved document has:
0xef 0xbb 0xbf before the <?xml...

What do I have to do to eliminate this? (.net 2.0)


Why do you want to do it?
AFAIK that's the Unicode Byte-Order-Marks wich every XML parser should
be able to understand.

Maybe a solution would be to switch to another encoding (US-ASCII,...)
--
Pascal Schmitt
Nov 12 '05 #2
I learn something new everyday - I was not aware of this. How long has this
been part of the standard?

--
thanks - dave
"Pascal Schmitt" wrote:
Hello!
XmlDocument doc = new XmlDocument();
doc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", ""));
...
doc.Save(outStream);

And my saved document has:
0xef 0xbb 0xbf before the <?xml...

What do I have to do to eliminate this? (.net 2.0)


Why do you want to do it?
AFAIK that's the Unicode Byte-Order-Marks wich every XML parser should
be able to understand.

Maybe a solution would be to switch to another encoding (US-ASCII,...)
--
Pascal Schmitt

Nov 12 '05 #3
David Thielen wrote:
I learn something new everyday - I was not aware of this. How long has
this been part of the standard?


Since the very beginning. The WD-xml-961114 draft says (4.2.3):

"Entities encoded in UCS-2 must begin with the Byte Order Mark
described by ISO 10646 Annex E and Unicode Appendix B (the ZERO
WIDTH NO-BREAK SPACE character, U+FEFF). This is an encoding
signature, not part of either the markup or character data of
the XML document. XML processors must be able to use this
character to differentiate between UTF-8 and UCS-2 encoded
documents." [p.20]

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Nov 12 '05 #4
David Thielen wrote:
I learn something new everyday - I was not aware of this. How long has this
been part of the standard?


I don't know...
But it's not directly part of XML - it's part of the Unicode-Standard
(and since XML 1.0 is based on Unicode 2.0, it must be older than this...)

The 3 bytes in your document are the Byte Order Mark for UTF-8, wich is
optional.

--
Pascal Schmitt

Nov 12 '05 #5
> The 3 bytes in your document are the Byte Order Mark for UTF-8, wich is
optional.


"Byte Order Mark" makes sense for Unicode where the characters are read and
written as 16 bit quantities and where the byte order depends on the
endianity, not for UTF-8 where the data is read and written as a byte
stream.

For UTF-8, this is rather a "signature".

Bruno
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2431
by: bissatch | last post by:
Hi, I am currently writing a simple PHP program that uses an XML file to output rows for a 'Whats New' page. Once written, I will only require updating the XML file and any pages that use the...
3
1303
by: Diwa | last post by:
In TC++PL 3edn, in section 21.2.2, Stroustrup notes that put( ) and write( ) simply write chars. Therefore, << for outputting chars need not be a member What does he mean here ? Also,...
0
444
by: Yobbo | last post by:
Hi All I have an ASP function in place to strip invalid chars out of a data store before I create an XML file of this data, but my function doesn't work on a certain set of chars. As far as I...
3
5641
by: Yobbo | last post by:
Hi All I have an ASP function in place to strip invalid chars out of a data store before I create an XML file of this data, but my function doesn't work on a certain set of chars. As far as I...
9
6137
by: Matthew | last post by:
I'm using PHP version 4.4.3. The manual page for PHP's mail() function (URL below) says that for the message (IE. email body) "Each line should be separated with a LF (\n). Lines should not be...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
6758
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7010
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4499
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3011
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.