Character ASCII checking

Powershell

Checking for non ASCII characters in a String

Function CheckLine($LineSpecChar){ 
    $Split = [regex]::split($linespecchar,"")
    $i=0
    foreach ($item in $split){
        $i++
        $ASCII = [int]$item[-0];
        if (!($ASCII -ge '32' -and $ASCII -le '123' -or $ASCII -eq '0')){
            Write-output "Character $i | '$item' | [$ASCII] | Not a valid ASCII Character in $linespecchar"
}}}

$line = "C:\Cluster–Storage\Volume–2\Server (Name – Location)"
CheckLine $line

 

About the Author

wvsandwijk

I am a Technical Specialist - Cloud Infrastructures from the Netherlands. My Skills are mainly PowerShell, VMWare, Hyper-V, Microsoft System Center products and Windows Azure Pack. I work for a company in Utrecht The Netherlands.

No Comments

Comments are closed.