源码中含有 '\357' '\273' '\277' 处理方法

来源:互联网 发布:windows的主要功能是 编辑:程序博客网 时间:2024/05/17 05:50

参考链接 http://stackoverflow.com/questions/1068650/using-awk-to-remove-the-byte-order-mark

Try this:

awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}{print}' INFILE > OUTFILE

On the first record (line), remove the BOM characters. Print every record.

Or slightly shorter, using the knowledge that the default action in awk is to print the record:

awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}1' INFILE > OUTFILE

1 is the shortest condition that always evaluates to true, so each record is printed.

Enjoy!

还有一个中文的参考链接 http://www.cnblogs.com/lidp/archive/2009/06/17/1697886.html

0 0
原创粉丝点击