Detect File Encoding (with Powershell)
As described in .net: Detect the encoding of a file this is a real doozy.
I have two powershell functions for this, neither of them perfect in every situation.
And I have a function for outputing and/or highlighting "unexpected" characters in a text file.
And one for (attempting) to convert the encoding.
External references
- Gist: jpoehls encoding-helpers.ps1
- Frank Richard: Powershell get encoding file type
- a port of Rick Strahl's Detecting Text Encoding for StreamReader