{"slug": "convert-all-files-to-utf-8-using-powershell", "title": "Convert all files to UTF-8 using powershell", "summary": "The article provides a PowerShell script named `Convert-Encoding.ps1` that converts files (specifically `.aspx`, `.master`, and `.cs` files) to UTF-8 without a Byte Order Mark (BOM). The script excludes certain directories and file patterns (like `**Debug**`, `**bin\\**`, and `*.Designer.cs`) and uses `System.Text.UTF8Encoding` to rewrite each file's content in UTF-8 encoding.", "body_md": "Convert-Encoding.ps1\n\n      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.\n      \nLearn more about bidirectional Unicode characters\n\n \n    Show hidden characters\n\n# encrypt files to utf-8 no bom \n\n\t[string[]]$Excludes = @('**Debug**', '** bin\\**', '*TemporaryGeneratedFile*.cs', '*.Designer.cs')\n\n\tGet-ChildItem .  -recurse -Include *.aspx, *.master, *.cs -Exclude $Excludes | ForEach-Object {\n\n\t\t$content = $_ | Get-Content \n\n\t\t$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False\n\n\t\t$_.Fullname\n\n\t\t[System.IO.File]::WriteAllLines($_.Fullname, $content, $Utf8NoBomEncoding) \n\n\t}", "url": "https://wpnews.pro/news/convert-all-files-to-utf-8-using-powershell", "canonical_source": "https://gist.github.com/jobou363/0d24a856246600d99e19776d4681d6ec", "published_at": "2018-07-27 19:22:15+00:00", "updated_at": "2026-05-23 14:06:41.234617+00:00", "lang": "en", "topics": ["developer-tools"], "entities": [], "alternates": {"html": "https://wpnews.pro/news/convert-all-files-to-utf-8-using-powershell", "markdown": "https://wpnews.pro/news/convert-all-files-to-utf-8-using-powershell.md", "text": "https://wpnews.pro/news/convert-all-files-to-utf-8-using-powershell.txt", "jsonld": "https://wpnews.pro/news/convert-all-files-to-utf-8-using-powershell.jsonld"}}