HandyWinGet icon indicating copy to clipboard operation
HandyWinGet copied to clipboard

Hard coded string caused crash in non-English locale

Open hongwen000 opened this issue 2 years ago • 4 comments

In src/HandyWinget/Common/Helper.cs, line 314; "Name" string is hard coded, however, winget process does not always return "Name" as the header. Instead, its output depends on locale.

            try
            {
                string input = _wingetData.Substring(_wingetData.IndexOf("Name"));
                var lines = input.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Skip(2);
                return lines;

            }

hongwen000 avatar Aug 30 '21 03:08 hongwen000

Same problems occur in functions for installing/uninstalling applications. Would this project be kind to support non-English locale? (This might be done by importing localization files from winget source code).

hongwen000 avatar Aug 30 '21 06:08 hongwen000

Thank you. There is currently no better way to identify installed apps and we have to use substring. I will try to support other languages as well

ghost1372 avatar Aug 30 '21 08:08 ghost1372

Thanks for your great work, I think substring with an additional translating function will be fine. I would like to try it when I'm done with my work at hand!

hongwen000 avatar Aug 30 '21 16:08 hongwen000

Using the translation method is the last way, we must look for a better way to parse data

ghost1372 avatar Aug 30 '21 16:08 ghost1372