Merge pull request #367 from guzy0324/main

bug fix for Get-WingetOutdatedApps when handling Chinese characters
pull/368/head
Romain 2023-07-22 11:33:08 +02:00 committed by GitHub
commit 741ab16479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 12 deletions

View File

@ -28,13 +28,13 @@ function Get-WingetOutdatedApps {
#Get header line #Get header line
$fl = $fl - 1 $fl = $fl - 1
#Get header titles #Get header titles [without remove seperator]
$index = $lines[$fl] -split '\s+' $index = $lines[$fl] -split '(?<=\s)(?!\s)'
# Line $fl has the header, we can find char where we find ID and Version # Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters]
$idStart = $lines[$fl].IndexOf($index[1]) $idStart = [System.Text.Encoding]::UTF8.GetByteCount($($index[0] -replace '[\u4e00-\u9fa5]', '**'))
$versionStart = $lines[$fl].IndexOf($index[2]) $versionStart = $idStart + [System.Text.Encoding]::UTF8.GetByteCount($($index[1] -replace '[\u4e00-\u9fa5]', '**'))
$availableStart = $lines[$fl].IndexOf($index[3]) $availableStart = $versionStart + [System.Text.Encoding]::UTF8.GetByteCount($($index[2] -replace '[\u4e00-\u9fa5]', '**'))
# Now cycle in real package and split accordingly # Now cycle in real package and split accordingly
$upgradeList = @() $upgradeList = @()
@ -44,13 +44,13 @@ function Get-WingetOutdatedApps {
#Get header line #Get header line
$fl = $i - 1 $fl = $i - 1
#Get header titles #Get header titles [without remove seperator]
$index = $lines[$fl] -split '\s+' $index = $lines[$fl] -split '(?<=\s)(?!\s)'
# Line $fl has the header, we can find char where we find ID and Version # Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters]
$idStart = $lines[$fl].IndexOf($index[1]) $idStart = [System.Text.Encoding]::UTF8.GetByteCount($($index[0] -replace '[\u4e00-\u9fa5]', '**'))
$versionStart = $lines[$fl].IndexOf($index[2]) $versionStart = $idStart + [System.Text.Encoding]::UTF8.GetByteCount($($index[1] -replace '[\u4e00-\u9fa5]', '**'))
$availableStart = $lines[$fl].IndexOf($index[3]) $availableStart = $versionStart + [System.Text.Encoding]::UTF8.GetByteCount($($index[2] -replace '[\u4e00-\u9fa5]', '**'))
} }
#(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") {