Re: How do I avoid writing the Byte Order Mark ?
- From: pamela fluente <pamelafluente@xxxxxxxxx>
- Date: Tue, 21 Aug 2007 09:12:33 -0700
On 20 Ago, 20:29, Kelly Ethridge <ke...@xxxxxxxxxxxxxxxxx> wrote:
pamela fluente wrote:
On 20 Ago, 17:36, Kelly Ethridge <ke...@xxxxxxxxxxxxxxxxx> wrote:
pamela fluente wrote:
On 20 Ago, 16:52, Göran Andersson <gu...@xxxxxxxxx> wrote:The default UTF8 encoding is set to write the preamble (BOM). Instead of
pamela fluente wrote:As I explained the file is read by browsers (it's a web page).
I am writing some text using something like:Then the problem is not the writing of the file, but the reading of the
Using FileStream As New FileStream(FileName, FileMode.Create)
Using StreamWriter As New StreamWriter(FileStream,
System.Text.Encoding.UTF8)
Try
StreamWriter.Write(Text)
FileStream.Flush()
...
QUESTION: How do I avoid writing the Byte Order Mark ?
It's for HTML pages: validator is complaining about the mark.
file. When the file the read, the BOM is not part of the file data.
If you read the file as a binary file instead of a text file, you don't
get an encoded string, you get a binary image of a unicode file.
The validator message is:
Byte-Order Mark found in UTF-8 File.
The Unicode Byte-Order Mark (BOM) in UTF-8 encoded files is known to
cause problems for some text editors and older browsers. You may want
to consider avoiding its use until it is better supported.
I am looking for a way NOT to write the BOM, because the validator
complains.
How do avoid the BOM writing ?
-P
using System.Text.Encoding.UTF8, you should create a new UTF8Encoding
object. By default, a new one won't include the the preamble (BOM).- Nascondi testo tra virgolette -
- Mostra testo tra virgolette -
If this is true, it is a simple solution.
I will try that. I am wondering why a new object would behave
differently (?)
-P
Well, one of the constructors for the UTF8Encoding class allows you to
include a BOM or not. If you use the default constructor then the
default is to not include the BOM.- Nascondi testo tra virgolette -
- Mostra testo tra virgolette -
Thanks! That works fine.
-P
.
- References:
- How do I avoid writing the Byte Order Mark ?
- From: pamela fluente
- Re: How do I avoid writing the Byte Order Mark ?
- From: Göran Andersson
- Re: How do I avoid writing the Byte Order Mark ?
- From: pamela fluente
- Re: How do I avoid writing the Byte Order Mark ?
- From: Kelly Ethridge
- Re: How do I avoid writing the Byte Order Mark ?
- From: pamela fluente
- Re: How do I avoid writing the Byte Order Mark ?
- From: Kelly Ethridge
- How do I avoid writing the Byte Order Mark ?
- Prev by Date: remove image tags in string
- Next by Date: Re: Disabling Items on a Context Menu in a Listview
- Previous by thread: Re: How do I avoid writing the Byte Order Mark ?
- Next by thread: Re: How do I avoid writing the Byte Order Mark ?
- Index(es):
Relevant Pages
|