Merge pull request #368 from guzy0324/main

Handle Chinese characters in apps' names
pull/370/head
Romain 2023-07-25 08:26:29 +02:00 committed by GitHub
commit be4d562425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -55,10 +55,12 @@ function Get-WingetOutdatedApps {
#(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()
$software.Name = $line.Substring(0, $idStart).TrimEnd() #Manage non latin characters
$software.Id = $line.Substring($idStart, $versionStart - $idStart).TrimEnd() $nameDeclination = $([System.Text.Encoding]::UTF8.GetByteCount($($line.Substring(0, $idStart) -replace '[\u4e00-\u9fa5]', '**')) - $line.Substring(0, $idStart).Length)
$software.Version = $line.Substring($versionStart, $availableStart - $versionStart).TrimEnd() $software.Name = $line.Substring(0, $idStart - $nameDeclination).TrimEnd()
$software.AvailableVersion = $line.Substring($availableStart).TrimEnd() $software.Id = $line.Substring($idStart - $nameDeclination, $versionStart - $idStart).TrimEnd()
$software.Version = $line.Substring($versionStart - $nameDeclination, $availableStart - $versionStart).TrimEnd()
$software.AvailableVersion = $line.Substring($availableStart - $nameDeclination).TrimEnd()
#add formated soft to list #add formated soft to list
$upgradeList += $software $upgradeList += $software
} }