问题
Current encoding is UTF-8 and I want to add BOM to all the files
Context: Windows 8 app certification toolkit throws following error, if BOM is not added:
File C:\x\y\z.js is not properly UTF-8 encoded. Re-save the file as UTF-8 (including Byte Order Mark).
回答1:
If you are using IDE like eclipse or netbeans, you can select all files and set the encoding. Other option is open all files in text editor and change.
回答2:
I know this is an old question but here is how I did it:
create a php file: addBOMtoFile.php and add the following line:
file_put_contents("some_new_file_name.js", "\xEF\xBB\xBF" . mb_convert_encoding(file_get_contents("some_file_name.js"), "UTF-8", "UTF-8"));
C:\php>php addBOMtoFile.php
来源:https://stackoverflow.com/questions/15222182/how-do-i-add-a-bom-to-all-utf-8-files-in-a-project