[Ubuntu] Remove Byte Order Mark (BOM) from files recursively [Forward article]
Original article: http://www.yiiframework.com/wiki/570/remove-byte-order-mark-bom-from-files-recursively/
The problem was that all my web applications ran normally on localhost, but on server the Greek characters (or any other no-english characters) displayed with problems.
So, I needed to remove BOM from hundreds view files of Yii from a lot of Yii projects manually. Netbeans has an option to keep files Encoding in utf-8 but not utf-8 without BOM.
My previous solution was the converting in utf-8 without BOM encoding one by one file on notepad++ consuming a lot of my time!
Many servers has not this issue but for other servers this is important. So, after of two hours searching I found a fast way to do that by commands.
(If you have windows, install cygwin first)
1) Open a shell command, go into your root folder that contains the project
2) Run this command
grep -rl $'\xEF\xBB\xBF' /home/rootfolder/Yii_project > file_with_boms.txt
3) Now, Run this one
while read l; do sed -i '1 s/^\xef\xbb\xbf//' $l; done < file_with_boms.txt
Thats it! The BOM will be removed from all files that contained it. Now you can upload your project on your server.
Note: Because I didn't use this way many times and I don't know if it works properly for all cases and files, make first a backup of your project! :)
shell script for replacing tab with spaces and remove bom head from file.
find /path/to/your/folder -type f -exec sed -i 's/\t/ /g' {} \; && grep -rl $'\xEF\xBB\xBF' /path/to/your/folder > file_with_boms.txt && while read l; do sed -i '1 s/^\xef\xbb\xbf//' $l; done < file_with_boms.txt && rm file_with_boms.txt
[Ubuntu] Remove Byte Order Mark (BOM) from files recursively [Forward article]的更多相关文章
- 字节顺序标记——BOM,Byte Order Mark
定义 BOM(Byte Order Mark),字节顺序标记,出现在文本文件头部,Unicode编码标准中用于标识文件是采用哪种格式的编码. 介绍 UTF-8 不需要 BOM,尽管 Unico ...
- LITTLE-ENDIAN(小字节序、低字节序) BOM——Byte Order Mark 字节序标记 数据在内存中的存放顺序
总结: 1. endian 字节存放次序 字节序,顾名思义字节的顺序,再多说两句就是大于一个字节类型的数据在内存中的存放顺序(一个字节的数据当然就无需谈顺序的问题了). 2. LITTLE-ENDIA ...
- UTF-8文件的Unicode签名BOM(Byte Order Mark)问题记录(EF BB BF)
背景 楼主测试的批量发送信息功能上线之后,后台发现存在少量的ERROR日志,日志内容为手机号码格式不正确. 此前测试过程中没有出现过此类问题,从运营人员拿到的发送列表的TXT,号码是符合规则的,且格式 ...
- StreamWriter结合UTF-8编码使用不当,会造成BOM(Byte Order Mark )问题生成乱码(转载)
问: I was using HttpWebRequest to try a rest api in ASP.NET Core MVC.Here is my HttpWebRequest client ...
- 文本编辑BOM标记(Byte Order Mark)
微软的自带记事本程序notepad.exe会给UTF-8编码的文件头加入三个隐藏的字节(即BOM).这是一种很愚蠢的做法.就是为了让编辑器不去猜测文件本身是ASCII码还是UTF-8. 什么是BOM ...
- 字节序(byte order)和位序(bit order)
字节序(byte order)和位序(bit order) 在网络编程中经常会提到网络字节序和主机序,也就是说当一个对象由多个字节组成的时候需要注意对象的多个字节在内存中的顺序. 以前我也基本只了 ...
- 编程-Byte order & Bit order
https://mp.weixin.qq.com/s/B9rKps4YsLiDTBkRks8rmQ 看到比特序和字节序放在一起被提及,想必就已经填补了概念拼图里面缺失的那一块了,这一块正是比特序. 一 ...
- ubuntu remove mysql
ubuntu 彻底删除 mysql 然后重装 mysql 删除 mysql sudo apt-get autoremove --purge mysql-server-5.0sudo apt-get r ...
- linux shell 命令学习(4) cut - remove sections from each line of files
之前写了split命令,split主要是按照行来进行文件的分割,而cut 是按照列来进行文件内容的选取 cut OPTION... [FILE]... 描述: 按列选取FILE的内容进行输出 -d : ...
随机推荐
- Selenium2学习-035-WebUI自动化实战实例-033-页面快照截图应用之三 -- 区域截图(专业版)
之前有写过两篇博文讲述了 WebUI 自动化测试脚本中常用的截图方法,敬请参阅如下所示链接: 浏览器显示区域截图 浏览器指定区域截图 那么当需要截取的区域不在浏览器显示窗口范围之内时,之前的方法显然无 ...
- Windows-004-显示文件的扩展名
此文主要讲述 Windows 7 下如何显示文件的扩展名,敬请亲们参阅.若有不足之处,敬请大神指正,不胜感激! 通常安装好 Win7 后,文件的扩展名默认是不显示的,如下所示: 点击工具栏中的 组织, ...
- 【转】Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用
Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用 分类: Android UI ...
- qt QString 与 int,char的转换
每次QString转换int或者char的时候都要查资料,记录一下,方便下次查看. 参考: http://blog.csdn.net/ei__nino/article/details/7297791 ...
- SpringMVC 406 accept请求错误,没有加入将json序列化的包
在spring中使用@responsebody发现请求报406错误 jar包中缺少json序列化的相关的包!
- 基础拾掇之——http基础
基础拾掇之——http基础 http协议介绍 http:Hyper Text Transfer Protocol 超文本传输协议,是互联网应用最为广泛的一种网络协议,主要用于Web服务.通过计算机处理 ...
- 微信支付开发(11) Native支付
关键字:微信公众平台 微信支付 Native原生支付作者:方倍工作室原文:http://www.cnblogs.com/txw1958/p/wxpay-native.html 由于微信支付接口更新,本 ...
- 第七篇 SQL Server代理作业活动监视器
本篇文章是SQL Server代理系列的第七篇,详细内容请参考原文 在这一系列的上一篇,你创建并配置SQL Server代理作业.每个作业有一个或多个步骤,可能包含大量的工作流.在这篇文章中,将查看作 ...
- Hello,HTML 到 HTML5
HTML5是WEB应用将发展到一个水平必要的技术. 下面是WEB发展的时间轴: 1991 - HTML 1994 - HTML2 1996 - CSS1 + JAVASCRIPT 1997 - HTM ...
- perl 学习杂项笔记
### 由于perl 语法属于很自由的那种, 建议出现错误的时候打开 -w 或者使用 -Mdiagnositics 试一下 ### 如何调试 perl程序 http://www.ibm.com/dev ...