473,396 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

EF BB BF prepended

guy
I have a routine that generates CSV files, the first character written is
ControlChars.Quote
this is done by means of System.IO.StreamWriter.Write(ControlChars.Quote)

and normally works correctly.

however if a large file (approx 14Mb) is generated the hex values as seen
with the Binary Editor EF BB BF appear immediately before the Quote character
(hex 22)

any idea what causes this / how to prevent it?

guy
Oct 9 '06 #1
2 30257
Hi,
however if a large file (approx 14Mb) is generated the hex values as seen
with the Binary Editor EF BB BF appear immediately before the Quote
character
(hex 22)
The three bytes are a so-called Byte Order Mark (BOM), which is used in
Unicode files:

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

In this case, EF BB BF means the file is a UTF-8 encoded file.
any idea what causes this / how to prevent it?
When you construct your StreamWriter class, you can specify the encoding you
want to use. For example, you could use the ASCII encoding, however this can
(will) cause problems if you write characters to your file that are not part
of the original ASCII table. As such, UTF-8 is a safe choice at least in the
Western world.

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethis.dystopia.fi
http://www.saunalahti.fi/janij/
Oct 9 '06 #2
>any idea what causes this / how to prevent it?
>
When you construct your StreamWriter class, you can specify the encoding you
want to use. For example, you could use the ASCII encoding, however this can
(will) cause problems if you write characters to your file that are not part
of the original ASCII table. As such, UTF-8 is a safe choice at least in the
Western world.
You can also create a new instance of UTF8Encoding, specify that it
shouldn't emit a BOM, and pass it to the SteamWriter.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Oct 12 '06 #3

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

Similar topics

4
by: Mxsmanic | last post by:
The require() I'm using in a PHP script has stopped working after I moved from PHP4 and Apache 1.3.x to PHP5 and Apache 2.x. Now I get messages like this: Warning:...
2
by: pbay | last post by:
Hi everyone, I'm experiencing a problem with PHP that doesn't seem to have any documentation related to it. I hope it's a simple error on my part :) Basically, I'm loading a SWF (Macromedia...
2
by: Dave Smithz | last post by:
Hi there. Because of the lack of a Union query in MySQL 3 I have decided to take the approach where I populate two arrays with values from similar tables in DB. In this case they are `courses`...
34
by: SeeBelow | last post by:
I see the value of a class when two or more instances will be created, but Python programmers regularly use a class when there will only be one instance. What is the benefit of this? It has a...
3
by: bernd wegener | last post by:
Hello netties, I coded the following in perl: open(LOGFILE,">&STDOUT") ; if ( $ARGV ) { close(LOGFILE) ; open(LOGFILE,">> $ARGV") or die "Cannot open file $ARGV\n" ;
4
by: MLH | last post by:
Seeking base 10 conversion for OCT and HEX numbers. I see A97 as OCT & HEX Fn's to convert decimal numbers to those 2 BASEs. What about the other way around?
1
by: needin4mation | last post by:
Hi, foreach (ListViewItem item in listViewFiles.Items) { MessageBox.Show(item.SubItems.Text + ", " + item.SubItems.Text); string source=item.SubItems.Text; string...
1
by: bg_ie | last post by:
Hi, I'm not happy with the way in which I use accessors and was wondering if there is a better way of defining them. Take the following example - class MyClass { // prepended to version...
5
scubak1w1
by: scubak1w1 | last post by:
Hello, I have a series of web sites which use https:// authentication (using AD integration to 'check the credentials' as it were) - all seems to be working well... I have been Googling et...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.