remove bom from utf-8 files - gists · GitHub
文章推薦指數: 80 %
remove bom from utf-8 files. GitHub Gist: instantly share code, notes, and snippets. Skiptocontent Allgists BacktoGitHub Signin Signup Sign in Sign up {{message}} Instantlysharecode,notes,andsnippets. svortex/bomremover CreatedMay23,2013 Star 0 Fork 0 Star Code Revisions 1 Embed Whatwouldyouliketodo? Embed Embedthisgistinyourwebsite. Share Copysharablelinkforthisgist. Clonevia HTTPS ClonewithGitorcheckoutwithSVNusingtherepository’swebaddress. LearnmoreaboutcloneURLs DownloadZIP removebomfromutf-8files Raw bomremover ThisfilecontainsbidirectionalUnicodetextthatmaybeinterpretedorcompileddifferentlythanwhatappearsbelow.Toreview,openthefileinaneditorthatrevealshiddenUnicodecharacters. LearnmoreaboutbidirectionalUnicodecharacters Showhiddencharacters #!/bin/bash # #BOMRemoverv1.0 # #(c)2011,AdilAliyev #NEATSLLC #Baku/Azerbaijan # #[email protected] # functionusage(){ echo"BOMRemoverv1.0" echo"" echo"(c)2011,AdilAliyev" echo"" echo"Usage:" echo"bomremover[-r]files..." echo"-rScansubdirectories." echo"" } RECURSIVE_MODE=false whilegetopts"rh"opt do case$optin r)RECURSIVE_MODE=true;; h)usage;exit1;; *)echo"Illegaloption.";exit2;; esac done FILES="$@" if[!-n"$FILES"];then echo"bomremover:Nofilespecified" exit1 fi color_greenf="\033[01;32m" color_reset="\033[0m" if[$RECURSIVE_MODE==true];then find.-typef|whilereadfile do sed-i's/^\xef\xbb\xbf//'"$file" echo-e"$file\t\t\t${color_greenf}done.${color_reset}"; done else foriin$FILES;do sed-i's/^\xef\xbb\xbf//'$i echo-e"$i\t\t\t${color_greenf}done.${color_reset}"; done fi #EOF Signupforfree tojointhisconversationonGitHub. Alreadyhaveanaccount? Signintocomment Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.
延伸文章資訊
- 1How can I remove the BOM from a UTF-8 file?
- 2Batch script remove BOM () from file - Stack Overflow
This is because the type command will preserve the UTF-8 BOM, so when you combine multiple files ...
- 3How to delete BOM from a string? - MSDN
Microsoft Logo. Gray Pipe ... How I can delete the BOM? Picture 1 and 2. bom1 bom 2 ... Remove(0,...
- 4BOM: What is a Byte Order Mark? - IONOS
If you want to remove the byte order mark from a source code, you need a text editor that offers ...
- 5How to display and remove BOM in utf-8 encoded file
Hi, I developed a website with Vim, working both on linux and windows and never had any problems....