diff --git a/Gui.ps1 b/Gui.ps1 index 8311d0e..7a0cd85 100644 --- a/Gui.ps1 +++ b/Gui.ps1 @@ -78,7 +78,7 @@ function Get-WingetAppInfo ($SearchApp) { } #Search for winget apps - $AppResult = & $Winget search $SearchApp --accept-source-agreements --source winget + $AppResult = & $Winget search $SearchApp --accept-source-agreements --source winget | Out-String #Start Convertion of winget format to an array. Check if "-----" exists if (!($AppResult -match "-----")) { @@ -99,21 +99,24 @@ function Get-WingetAppInfo ($SearchApp) { $fl = $fl - 1 - #Get header titles - $index = $lines[$fl] -split '\s+' + #Get header titles [without remove seperator] + $index = $lines[$fl] -split '(?<=\s)(?!\s)' - # Line $fl has the header, we can find char where we find ID and Version - $idStart = $lines[$fl].IndexOf($index[1]) - $versionStart = $lines[$fl].IndexOf($index[2]) + # Line $fl has the header, we can find char where we find ID and Version [and manage non latin characters] + $idStart = $($index[0] -replace '[\u4e00-\u9fa5]', '**').Length + $versionStart = $idStart + $($index[1] -replace '[\u4e00-\u9fa5]', '**').Length # Now cycle in real package and split accordingly $searchList = @() For ($i = $fl + 2; $i -le $lines.Length; $i++) { - $line = $lines[$i] - if ($line.Length -gt ($sourceStart + 5)) { + $line = $lines[$i] -replace "[\u2026]", " " #Fix "..." in long names + # If line contains an ID (Alphanumeric | Literal "." | Alphanumeric) + if ($line -match "\w\.\w") { $software = [Software]::new() - $software.Name = $line.Substring(0, $idStart).TrimEnd() - $software.Id = $line.Substring($idStart, $versionStart - $idStart).TrimEnd() + #Manage non latin characters + $nameDeclination = $($line.Substring(0, $idStart) -replace '[\u4e00-\u9fa5]', '**').Length - $line.Substring(0, $idStart).Length + $software.Name = $line.Substring(0, $idStart - $nameDeclination).TrimEnd() + $software.Id = $line.Substring($idStart - $nameDeclination, $versionStart - $idStart).TrimEnd() #add formated soft to list $searchList += $software } @@ -398,7 +401,7 @@ function Start-InstallGUI { - + @@ -482,7 +485,7 @@ function Start-InstallGUI { "@ #Create window - [xml]$XAML = ($inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^