mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 10:38:47 +08:00
add remove_utf8_bom
This commit is contained in:
parent
df1a91e8a7
commit
f0d1687e05
@ -1,4 +1,7 @@
|
||||
# 最新动态
|
||||
* 2020/03/24
|
||||
* 增加工具 remove\_utf8\_bom
|
||||
|
||||
* 2020/03/23
|
||||
* 增加函数 tk_strlen。
|
||||
* 完善圆角矩形(感谢智明提供补丁)。
|
||||
|
11
tools/remove_utf8_bom/README.md
Normal file
11
tools/remove_utf8_bom/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# 去掉UTF-8前的BOM
|
||||
|
||||
有的编译器不支持UTF-8 BOM,此时需要取到去掉UTF-8 BOM文件的BOM.
|
||||
|
||||
用法(bash):
|
||||
|
||||
```
|
||||
find src -name \*.h -exec node tools/remove_utf8_bom/index.js {} \;
|
||||
```
|
||||
|
||||
> 请安装[nodejs](https://nodejs.org)。
|
12
tools/remove_utf8_bom/index.js
Normal file
12
tools/remove_utf8_bom/index.js
Normal file
@ -0,0 +1,12 @@
|
||||
var fs = require('fs');
|
||||
var options = {encoding:"utf8"};
|
||||
|
||||
var filename = process.argv.length > 2 ? process.argv[2] : "test.c";
|
||||
|
||||
var content = fs.readFileSync(filename).toString();
|
||||
if(content.charCodeAt(0) === 0xfeff) {
|
||||
content = content.substr(1);
|
||||
fs.writeFileSync(filename, content, options);
|
||||
console.log(filename + " done");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user