• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 634
  • Last Modified:

Delphi add BOM to files

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
pucko73
Asked:
pucko73
  • 2
  • 2
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
Why?  It's not recommended for files for the web.
0
 
pucko73Author Commented:
Tell that to the people that made the "parsing in the receiving application"  and that read all files without BOM as ANSI encoded.
0
 
Dave BaldwinFixer of ProblemsCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
sepidehdamCommented:
Help to guide delphi 7
"ALTER TABLE add column.
By coding with Delphi 7
0
 
sepidehdamCommented:
Help to guide delphi 7
"ALTER TABLE add column.
By coding with Delphi 7
0
 
pucko73Author Commented:
???
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now