Fix double-byte and half-width characters
parent
7ce2eb2146
commit
9aeb8a2e4f
|
@ -32,9 +32,9 @@ function Get-WingetOutdatedApps {
|
||||||
$index = $lines[$fl] -split '(?<=\s)(?!\s)'
|
$index = $lines[$fl] -split '(?<=\s)(?!\s)'
|
||||||
|
|
||||||
# Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters]
|
# Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters]
|
||||||
$idStart = [System.Text.Encoding]::UTF8.GetByteCount($($index[0] -replace '[\u4e00-\u9fa5]', '**'))
|
$idStart = $($index[0] -replace '[\u4e00-\u9fa5]', '**').Length
|
||||||
$versionStart = $idStart + [System.Text.Encoding]::UTF8.GetByteCount($($index[1] -replace '[\u4e00-\u9fa5]', '**'))
|
$versionStart = $idStart + $($index[1] -replace '[\u4e00-\u9fa5]', '**').Length
|
||||||
$availableStart = $versionStart + [System.Text.Encoding]::UTF8.GetByteCount($($index[2] -replace '[\u4e00-\u9fa5]', '**'))
|
$availableStart = $versionStart + $($index[2] -replace '[\u4e00-\u9fa5]', '**').Length
|
||||||
|
|
||||||
# Now cycle in real package and split accordingly
|
# Now cycle in real package and split accordingly
|
||||||
$upgradeList = @()
|
$upgradeList = @()
|
||||||
|
@ -48,15 +48,15 @@ function Get-WingetOutdatedApps {
|
||||||
$index = $lines[$fl] -split '(?<=\s)(?!\s)'
|
$index = $lines[$fl] -split '(?<=\s)(?!\s)'
|
||||||
|
|
||||||
# Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters]
|
# Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters]
|
||||||
$idStart = [System.Text.Encoding]::UTF8.GetByteCount($($index[0] -replace '[\u4e00-\u9fa5]', '**'))
|
$idStart = $($index[0] -replace '[\u4e00-\u9fa5]', '**').Length
|
||||||
$versionStart = $idStart + [System.Text.Encoding]::UTF8.GetByteCount($($index[1] -replace '[\u4e00-\u9fa5]', '**'))
|
$versionStart = $idStart + $($index[1] -replace '[\u4e00-\u9fa5]', '**').Length
|
||||||
$availableStart = $versionStart + [System.Text.Encoding]::UTF8.GetByteCount($($index[2] -replace '[\u4e00-\u9fa5]', '**'))
|
$availableStart = $versionStart + $($index[2] -replace '[\u4e00-\u9fa5]', '**').Length
|
||||||
}
|
}
|
||||||
#(Alphanumeric | Literal . | Alphanumeric) - the only unique thing in common for lines with applications
|
#(Alphanumeric | Literal . | Alphanumeric) - the only unique thing in common for lines with applications
|
||||||
if ($line -match "\w\.\w") {
|
if ($line -match "\w\.\w") {
|
||||||
$software = [Software]::new()
|
$software = [Software]::new()
|
||||||
#Manage non latin characters
|
#Manage non latin characters
|
||||||
$nameDeclination = $([System.Text.Encoding]::UTF8.GetByteCount($($line.Substring(0, $idStart) -replace '[\u4e00-\u9fa5]', '**')) - $line.Substring(0, $idStart).Length)
|
$nameDeclination = $($line.Substring(0, $idStart) -replace '[\u4e00-\u9fa5]', '**').Length - $line.Substring(0, $idStart).Length
|
||||||
$software.Name = $line.Substring(0, $idStart - $nameDeclination).TrimEnd()
|
$software.Name = $line.Substring(0, $idStart - $nameDeclination).TrimEnd()
|
||||||
$software.Id = $line.Substring($idStart - $nameDeclination, $versionStart - $idStart).TrimEnd()
|
$software.Id = $line.Substring($idStart - $nameDeclination, $versionStart - $idStart).TrimEnd()
|
||||||
$software.Version = $line.Substring($versionStart - $nameDeclination, $availableStart - $versionStart).TrimEnd()
|
$software.Version = $line.Substring($versionStart - $nameDeclination, $availableStart - $versionStart).TrimEnd()
|
||||||
|
|
Loading…
Reference in New Issue