?
Solved

Delphi add BOM to files

Posted on 2014-04-23
6
Medium Priority
?
615 Views
Last Modified: 2014-06-15
I want to add a utf8 bom to files that don't have it.

(ie 0xEF,0xBB,0xBF  in the beginning)

Can someone give me some code to check the 3 first bytes of a file and insert the bom if missing?
0
Comment
Question by:pucko73
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40019352
Why?  It's not recommended for files for the web.
0
 

Author Comment

by:pucko73
ID: 40019364
Tell that to the people that made the "parsing in the receiving application"  and that read all files without BOM as ANSI encoded.
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 40019377
Ok, good reason.  I don't have the actual code to give you.  You need to open the files in binary mode and read those first bytes.  If they're not there, then you put them in the write buffer and read the rest of the file into it after them as basically a file copy routine.  Then write the file out, usually under a temp name, close the files delete the original, and rename the new version.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Expert Comment

by:sepidehdam
ID: 40114349
Help to guide delphi 7
"ALTER TABLE add column.
By coding with Delphi 7
0
 

Expert Comment

by:sepidehdam
ID: 40114411
Help to guide delphi 7
"ALTER TABLE add column.
By coding with Delphi 7
0
 

Author Comment

by:pucko73
ID: 40136264
???
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question