Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Get text encoding of files
- ## from js2010 on https://stackoverflow.com/questions/3825390/effective-way-to-find-any-files-encoding
- foreach($filename in $args)
- {
- ##$reader = [System.IO.StreamReader]::new($filename, [System.Text.Encoding]::default,$true)
- ## changed to work with earlier (legacy) PowerShell versions
- if( $reader = New-Object -TypeName System.IO.StreamReader -ArgumentList @($filename, [System.Text.Encoding]::default,$true) )
- {
- $peek = $reader.Peek()
- $reader.currentencoding | Select-Object -property @{n='File';e={$filename}},bodyname,encodingname
- $reader.close()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement