支持HW团队,就支付宝领取下面的红包吧! (打开支付宝就能领取!er1OEj73Uj), (打开支付宝收索“516503473”), 你领取消费,HW有奖励。红包使用无条件限制,有条件请注意是不是有病毒。

Login or Sign up | Validate
| Search

博主:初学MPEG

初学MPEG 本博客-采用Python的web框架Django与Mysql数据库,致力于对Python、Django的了解 与研究
Django技术QQ群:XXXXXXX
Python技术QQ群:XXXXXXX

Category

Keywords

本站最新博文

友情链接  

[转]批量删除UTF-8编码中BOM字符

类别:linux 状态:游客可见,可回,会员可关联(良好) 阅读:9964 评论:0 时间:May 22, 2012, 11:39 a.m.
关键字:

 在Linux下编译一个同事打包过来的C项目工程,编译步骤很简单,只有一步:make,问题是报错一堆错:

...
gcc -fno-strict-aliasing -DNDEBUG -DSF_LIBEAL_USE_HPET -O2 -DSF_LITTLE_ENDIAN -W -Wall -Wno-pointer-sign -Wno-unused-parameter -I... -MD -c -o obj/xxx.c
In file included from /.../xxx.h:17,
from /.../xxx.h:5,
from xxx.c:34:
/.../xxx.h:1: error: stray '\357' in program
/.../xxx.h:1: error: stray '\273' in program
/.../xxx.h:1: error: stray '\277' in program
make[2]: *** [obj/xxx.o] Error 1
make[2]: Leaving directory `/.../xxx'
make[2]: Leaving directory `/.../xxx'
gcc -fno-strict-aliasing -DNDEBUG -DSF_LIBEAL_USE_HPET -O2 -DSF_LITTLE_ENDIAN -W -Wall -Wno-pointer-sign -Wno-unused-parameter -I... -MD -c -o obj/xxx.c
In file included from /.../xxx.h:17,
from /.../xxx.h:5,
from xxx.c:34:
/.../xxx.h:1: error: stray '\357' in program
/.../xxx.h:1: error: stray '\273' in program
/.../xxx.h:1: error: stray '\277' in program
make[2]: *** [obj/xxx.o] Error 1
make[2]: Leaving directory `/.../xxx'
make[2]: Leaving directory `/.../xxx'
...


这是什么错误?这是UTF-8编码中BOM字符引起的gcc编译出错,BOM(Byte Order Mark)是Windows下的东东,Linux下根本就不需要它,那直接批量去掉吧:
[root@localhost xxx]# grep -rIlo $'^\xEF\xBB\xBF' . | xargs sed --in-place -e 's/\xef\xbb\xbf//'
温馨提

操作:

Please Login (or Sign Up) to leave a comment