openvr icon indicating copy to clipboard operation
openvr copied to clipboard

Using UTF8 BOM encoding for config files makes loading them fail

Open BOLL7708 opened this issue 5 years ago • 2 comments

Luckily I knew this from previous experience now when working on a new project, but it had me bewildered the first time around.

Currently I'm using Visual Studio 2019, and at least for me creating a new text file will default to UTF8 BOM and not UTF8. This will have OpenVR/SteamVR invariably fail to load external config files created this way, files like the app.vrmanifest, actions.json and whatever_bindings.json. This until I manually switch the text encoding to UTF8. 😔

For the app manifest the web console will output "Errors when parsing manifest file: * Line 1 Column 1" and then list off what looks like proper JSON. For the .json files it will output "Parsing of JSON string "[entire JSON file contents]" failed: * Line 1 Column 1".

The essential clue is that the error is always at line 1, column 1, so seemingly after the first newline. Still, not sure if this is helpful enough for most people, or if the web console's existence is even general knowledge. 😅

What would be an appropriate fix? Any of the below could work I guess.

  1. Detect UTF8 BOM and convert to UTF8 at runtime
  2. More granular error reporting for the parsing in the console
  3. Mention that UTF8 BOM encoding is not supported in the wiki

Something along those lines. 😗

BOLL7708 avatar May 28 '20 13:05 BOLL7708

Wasn't sure if this was still an issue, but still happens if I change the encoding of my app.vrmanifest as of OpenVR 1.12.5 and SteamVR beta 1.13.10 😅 I have noticed in the code that there exists a RepairUTF8 function, so maybe it's just one additional option that could go in there to fix this 😗 Although maybe it would be a conversion and not a repair.

BOLL7708 avatar Jul 12 '20 11:07 BOLL7708

I have experienced the same issue and also had to change the encoding. In my case it was the IDE Rider I used to create the file and it also created a UTF8 BOM file.

jeppevinkel avatar Sep 03 '21 11:09 jeppevinkel