Andrewthe13th / Inventory_Kamera

Scans Genshin Impact characters, artifacts, and weapons from the game window into a JSON file.
MIT License
699 stars 122 forks source link

[BUG] Unable to obtain inventorylists for new version #298

Closed Maelstrom-Portal closed 2 years ago

Maelstrom-Portal commented 2 years ago

NOTE Please describe on each question as much as you can. This will speeds up our bug fixing process.

What happed? What is seems to be a bug?

Unable to obtain inventorylists for new version due to:

  1. "Game Version Update" shows "Could not check for updates" after a long pause.
  2. "Update Lookup Tables" throws Newtonsoft.Json.JsonReaderException after a long pause.

How to reproduce this issue

  1. On "Game Version Update" popup, click "Yes".
  2. Click "Update Lookup Tables"

    What seems to cause this issue?

    Newtonsoft.Json.JsonReaderException

Expected behavior

Obtain inventorylists successfully for new version of Inventory Kamera

Info about your device

Additional Notes / Remarks

InventoryKamera.debug.log Similar issue?: https://github.com/Andrewthe13th/Inventory_Kamera/issues/120

Checklist before sending issue

Instruction: Check the tickbox by replacing [ ] with [x] (in editor) or tick it after leaving the Text Editor:

Additional checklist for Scanning issues

emerua commented 2 years ago

I have encountered the same issue. I'm Japanese and I'm not good at English, so I'm sorry if the sentences are wrong.

Probably because the UTF8 encoding was not specified when reading the textMap json. I've checked it in my local environment and it seems that the following fixes work, but I'm not confident. I hope this info helps contributors.

add client.Encoding = System.Text.Encoding.UTF8; to LoadJsonFromURLAsync

        private string LoadJsonFromURLAsync(string url)
        {
            string json = "";
            using (WebClient client = new WebClient())
            {
                client.Encoding = System.Text.Encoding.UTF8;
                json = client.DownloadString(url);
            }
            return json;
        }
Cupcak3 commented 2 years ago

@emerua Thanks for looking at this. It does seem at least related and doesn't break anything for me so I'll add it in.

JirgCode commented 2 years ago

Changing my computers unicode language from japanese->english fixed the error for me

Maelstrom-Portal commented 2 years ago

Changing my computers unicode language from japanese->english fixed the error for me

For windows users, if you don't want to change your system locale to english, follow this guide: https://www.java.com/en/download/help/locale.html

However, instead of selecting the desired language in step 5, check the box of "Beta: Use Unicode UTF-8 for worldwide language support" and you are good to go.