remove utf-8 bom with javascript - gists · GitHub

文章推薦指數: 80 %
投票人數:10人

remove utf-8 BOM from ressource "res". // res.charCodeAt(0) === 0xFEFF | res.charCodeAt(0) === 65279. if (res.charCodeAt(0) === 0xFEFF) {. Skiptocontent Allgists BacktoGitHub Signin Signup Sign in Sign up {{message}} Instantlysharecode,notes,andsnippets. antic183/remove-utf8-bom.js LastactiveOct9,2022 Star 20 Fork 2 Star Code Revisions 4 Stars 20 Forks 2 Embed Whatwouldyouliketodo? Embed Embedthisgistinyourwebsite. Share Copysharablelinkforthisgist. Clonevia HTTPS ClonewithGitorcheckoutwithSVNusingtherepository’swebaddress. LearnmoreaboutcloneURLs DownloadZIP removeutf-8bomwithjavascript Raw remove-utf8-bom.js ThisfilecontainsbidirectionalUnicodetextthatmaybeinterpretedorcompileddifferentlythanwhatappearsbelow.Toreview,openthefileinaneditorthatrevealshiddenUnicodecharacters. LearnmoreaboutbidirectionalUnicodecharacters Showhiddencharacters //removeutf-8BOMfromressource"res" //res.charCodeAt(0)===0xFEFF|res.charCodeAt(0)===65279 if(res.charCodeAt(0)===0xFEFF){ res=res.substr(1); } Copylink matthewmb commented Oct12,2018 Thankyou.Thiswasthefinalsolutiontohoursoffrustration. Sorry,somethingwentwrong. Copylink dharb commented Jan15,2020 Seconded.Whatanightmare,thankyousomuchforsharingthis. Sorry,somethingwentwrong. Copylink eladkarako commented Dec3,2020 • edited one-lineralternative res=res.replace(/^\uFEFF/gm,""); orbetteryet: res=res.replace(/^\uFEFF/gm,"").replace(/^\u00BB\u00BF/gm,""); Sorry,somethingwentwrong. Copylink Darker commented May12,2021 Whatisthesecondonefor? Sorry,somethingwentwrong. Copylink brdacost commented Jul29,2021 up Sorry,somethingwentwrong. Copylink cescoallegrini commented Oct9,2022 Whatisthesecondonefor? @DarkerthosearetheBOMrepresentationinexcelfiles(»¿),oratleastpartofit. AsfarasIknowthefulloutputis,sotheregexshouldbe res=res.replace(/^\uFEFF/gm,"").replace(/^\u00EF?\u00BB\u00BF/gm,""); Sorry,somethingwentwrong. Signupforfree tojointhisconversationonGitHub. Alreadyhaveanaccount? Signintocomment Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.



請為這篇文章評分?