internal/functions/Get-CodePage.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function Get-CodePage {
    <#
        .SYNOPSIS
            Converts Microsoft's code page ID to human readable format
 
        .DESCRIPTION
            Converts Microsoft's code page ID to human readable format
 
        .PARAMETER Id
            The code page ID
 
        .EXAMPLE
            Get-CodePage 1252
 
            Returns a pscustomobject with id, alias and name
    #>

    [CmdletBinding()]
    param (
        [int]$id
    )
    process {
        $encoding = [System.Text.Encoding]::GetEncoding($id)
        $IncludeProps = 'CodePage', 'BodyName', 'EncodingName', 'HeaderName', 'WebName', 'IsSingleByte'
        Select-DefaultView -InputObject $encoding -Property $IncludeProps
    }
}