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]的更多相关文章

  1. 字节顺序标记——BOM,Byte Order Mark

    定义 BOM(Byte Order Mark),字节顺序标记,出现在文本文件头部,Unicode编码标准中用于标识文件是采用哪种格式的编码.     介绍 UTF-8 不需要 BOM,尽管 Unico ...

  2. LITTLE-ENDIAN(小字节序、低字节序) BOM——Byte Order Mark 字节序标记 数据在内存中的存放顺序

    总结: 1. endian 字节存放次序 字节序,顾名思义字节的顺序,再多说两句就是大于一个字节类型的数据在内存中的存放顺序(一个字节的数据当然就无需谈顺序的问题了). 2. LITTLE-ENDIA ...

  3. UTF-8文件的Unicode签名BOM(Byte Order Mark)问题记录(EF BB BF)

    背景 楼主测试的批量发送信息功能上线之后,后台发现存在少量的ERROR日志,日志内容为手机号码格式不正确. 此前测试过程中没有出现过此类问题,从运营人员拿到的发送列表的TXT,号码是符合规则的,且格式 ...

  4. 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 ...

  5. 文本编辑BOM标记(Byte Order Mark)

    微软的自带记事本程序notepad.exe会给UTF-8编码的文件头加入三个隐藏的字节(即BOM).这是一种很愚蠢的做法.就是为了让编辑器不去猜测文件本身是ASCII码还是UTF-8. 什么是BOM ...

  6. 字节序(byte order)和位序(bit order)

    字节序(byte order)和位序(bit order)  在网络编程中经常会提到网络字节序和主机序,也就是说当一个对象由多个字节组成的时候需要注意对象的多个字节在内存中的顺序.  以前我也基本只了 ...

  7. 编程-Byte order & Bit order

    https://mp.weixin.qq.com/s/B9rKps4YsLiDTBkRks8rmQ 看到比特序和字节序放在一起被提及,想必就已经填补了概念拼图里面缺失的那一块了,这一块正是比特序. 一 ...

  8. ubuntu remove mysql

    ubuntu 彻底删除 mysql 然后重装 mysql 删除 mysql sudo apt-get autoremove --purge mysql-server-5.0sudo apt-get r ...

  9. linux shell 命令学习(4) cut - remove sections from each line of files

    之前写了split命令,split主要是按照行来进行文件的分割,而cut 是按照列来进行文件内容的选取 cut OPTION... [FILE]... 描述: 按列选取FILE的内容进行输出 -d : ...

随机推荐

  1. node.js的exprots工厂模式

    工厂类: /** * Created by zzq on 2015/5/15. */ module.exports = function(){ this.getProduct = function() ...

  2. 【C++】C++求vector中的最大最小值

    利用algorithm库里的max_element和min_element可以得到vector的最大最小值,配合distance函数可以得到最大值的位置 #include<vector> ...

  3. LightOj1074 - Extended Traffic(SPFA最短路)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1074 题意:有n个城市,每个城市有一个拥堵值a[i],m条单向路u到v,从u到v所需时 ...

  4. logback配置详解(二)

    <appender> <appender>: <appender>是<configuration>的子节点,是负责写日志的组件. <appende ...

  5. OPENCV3.1+VS 坑我笔记!

    1.调用findContours()函数程序崩溃. 原因: >>分析opencv源代码,跟踪测试,进入工程:opencv_imgproc 发现findContours函数 是调用 _fin ...

  6. AD834+表面声波滤波器调试小结

    AD834:带宽较宽,300M无压力,但是输出幅度小,当输入2VPPX2VPP的时候最大输出400mVPP.一个特别要注意的地方是输入走线尽量短,敷铜间距至少满足3倍线宽,不然隔直之后还会耦合信号进去 ...

  7. C#反射代码

    Object model=Assembly.Load(“程序集”).CreateInstance(命名空间.类名); object obj2 = Type.GetType("MyClass& ...

  8. 使用nmcli创建网络连接

    使用nmcli创建一个新的网络连接时,首先需要清楚几个概念 设备即接口 连接是供设备使用的配置,其由一组设置组成. 同一个设备可能存在多个连接,但是一次只能有一个保持活动状态 在创建新的连接时,参数的 ...

  9. Bugfree实用心得_转

    转自:http://blog.csdn.net/benkaoya/article/details/8719257 本博下有许多实用技巧 1. 什么是问题跟踪系统 问题跟踪系统(Issue Tracki ...

  10. tableview head

    http://stackoverflow.com/questions/18880341/why-is-there-extra-padding-at-the-top-of-my-uitableview- ...