Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal number format changes with language #6

Closed
blurpy opened this issue Dec 31, 2020 · 5 comments
Closed

Decimal number format changes with language #6

blurpy opened this issue Dec 31, 2020 · 5 comments

Comments

@blurpy
Copy link

blurpy commented Dec 31, 2020

I received a report from a German user that QA401W isn't displaying anything, but that requests seem to go OK between the browser and QA401H. I was able to reproduce, and it looks like this after doing an acquisition:

qa401-german

There are no errors in the log of QA401H, and no errors in the console or network tab of the developer tools in the browser.

What happens is that if you configure your OS (at least on Linux) to some languages, the number format changes, and QA401H adapts. The browser does not though, so the JSON parser fails to interpret the numbers.

This is how it is normally for me:

curl -d "" -X PUT http://localhost:9401/Settings/AudioGen/Gen1/On/1000/0 
{ "SessionId":"0" }

curl -d "" -X POST http://localhost:9401/Acquisition 
{ "SessionId":"2290222104" }

curl http://localhost:9401/Phase/Seconds 
{ "SessionId":"2290222104", "Left":"0.00020784909723370925", "Right":"0.00020576029083909996" }

curl http://localhost:9401/ThdDb/1000/20000
{ "SessionId":"2290222104", "Left":"-102.82025498084323", "Right":"-102.46467345532238" }

curl http://localhost:9401/ThdPct/1000/20000
{ "SessionId":"2290222104", "Left":"0.0007227485864607289", "Right":"0.0007529503287253446" }

Floats use period as the decimal separator.

This is how it looks if I change the language to German:

curl -d "" -X PUT http://localhost:9401/Settings/AudioGen/Gen1/On/1000/0 
{ "SessionId":"0" }

curl -d "" -X POST http://localhost:9401/Acquisition 
{ "SessionId":"3592625235" }

curl http://localhost:9401/Phase/Seconds 
{ "SessionId":"3592625235", "Left":"0,0005415564663523863", "Right":"0,0005391615949382826" }

curl http://localhost:9401/ThdDb/1000/20000
{ "SessionId":"3592625235", "Left":"-102,99914694724458", "Right":"-102,03344721080657" }

curl http://localhost:9401/ThdPct/1000/20000
{ "SessionId":"3592625235", "Left":"0,0007080153160940537", "Right":"0,00079127535504247" }

Suddenly floats use comma as the decimal separator.

I started QA401H like this to reproduce:

LANG="de_DE.UTF-8" dotnet QA401H.dll

It looks like the JSON standard expect floats to use period as the separator:

That also seems consistent with the behaviour the user experienced.
Is it possible to make QA401H return a consistent number format no matter the language?

@QuantAsylum
Copy link
Owner

I'm not able to repro, but you are right that json should not change depending on language + culture.

The attached version has made the output culture-invariant, which should yield the needed behavior. I first tried on 0.999. I tried to force:

set DOTNET_CLI_UI_LANGUAGE=de_DE

And then, asking dotnet for --help gives

.NET Core SDK (3.1.301)
Syntax: dotnet [runtime-options] [path-to-application] [arguments]

Hiermit wird eine .NET Core-Anwendung ausgeführt.

runtime-options:
  --additionalprobingpath <path>   Pfad, der die Suchrichtlinie und die zu suchenden Assemblys enthält.
  --additional-deps <path>         Pfad zur zusätzlichen Datei "deps.json".

So the language did change. But then doing an acq and

http://localhost:9401/RmsDbv/20/20000

gives the following:

image

This has the decimal points as periods in spite of being in German on version 0.999. But this might not be a surprise because sometimes you can't switch culture completely. In any case, the outputs should be cultural invariant for 0.9991 if you have time to try. Looks like this release also has correction to phase inversion on inputs.

QA401H_v0.9991.zip

@blurpy
Copy link
Author

blurpy commented Jan 1, 2021

Thanks! I tested it and it now works for me with German language, as well as English.
I will ask the user to verify as well, to make sure.

@blurpy
Copy link
Author

blurpy commented Jan 1, 2021

Regarding phase, it's definitely different now.

This is how phase used to look, in loopback:

qa401-999-phase

And now it's like this:

qa401-9991-phase

Does it look like expected?

@blurpy
Copy link
Author

blurpy commented Jan 1, 2021

I got a confirmation that v0.9991 works like it should with German language setup!

@blurpy
Copy link
Author

blurpy commented Jan 12, 2021

Still curious about whether that negative phase is expected in the new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants