Hi,
I've got some files that are UTF-8 encoded, but without the byte-order-marker. I know there must be a way to add the needed characters to the beginning of these files, but I'm not sure how to do it.
Any ideas?
Thanks!
andy
How to add a UTF-8 Byte-order-marker to a file?
Re: How to add a UTF-8 Byte-order-marker to a file?
So, did I just discover that there's no easy way for reading/writing raw bytes in XY?
this a workaround:WARNING: this doesn't check if the input file is UTF8-encoded, already has BOM, or even if it is a textfile at all. This just blindly adds the BOM characters to the beginning of the input file.
this a workaround:
Code: Select all
"add bom to file"
$file = "UTF8_file_without_BOM.txt";
writefile($file, hexdump('EFBBBF',2,'ri').readfile($file,'b'), , 'b');
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: How to add a UTF-8 Byte-order-marker to a file?
Thanks, Sammay! Works great!