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?
pucko73Asked:
Who is Participating?
 
Dave BaldwinConnect With a Mentor Fixer 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
 
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.