Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,47 @@
function Remove-Character
{
[CmdletBinding(DefaultParameterSetName="Control and Extended")]
[OutputType([string])]
Param
(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[string]
$String,
[Parameter(ParameterSetName="Control")]
[switch]
$Control,
[Parameter(ParameterSetName="Extended")]
[switch]
$Extended
)
Begin
{
filter Remove-ControlCharacter
{
$_.ToCharArray() | ForEach-Object -Begin {$out = ""} -Process {if (-not [Char]::IsControl($_)) {$out += $_ }} -End {$out}
}
filter Remove-ExtendedCharacter
{
$_.ToCharArray() | ForEach-Object -Begin {$out = ""} -Process {if ([int]$_ -lt 127) {$out += $_ }} -End {$out}
}
}
Process
{
foreach ($s in $String)
{
switch ($PSCmdlet.ParameterSetName)
{
"Control" {$s | Remove-ControlCharacter}
"Extended" {$s | Remove-ExtendedCharacter}
Default {$s | Remove-ExtendedCharacter | Remove-ControlCharacter}
}
}
}
}

View file

@ -0,0 +1,6 @@
$test = "$([char]9)Français."
"Original string : `"$test`""
"Control characters stripped : `"$($test | Remove-Character -Control)`""
"Extended characters stripped : `"$($test | Remove-Character -Extended)`""
"Control & extended stripped : `"$($test | Remove-Character)`""

View file

@ -0,0 +1 @@
"Français", "Čeština" | Remove-Character -Extended