0

A unit test is failing. The very brief of it is:

decimal.TryParse("123,456", out decimal d)
Assert.AreEqual(d, 123.456);

Thread.CurrentThread.CurrentUICulture and Thread.CurrentThread.CurrentCulture both return en-US during the test, but cat /etc/default/locale prints

LANG=en_DK.UTF-8
LC_NUMERIC=en_DK.UTF-8
LC_TIME=en_DK.UTF-8
LC_MONETARY=en_DK.UTF-8
LC_PAPER=en_DK.UTF-8
LC_NAME=en_DK.UTF-8
LC_ADDRESS=en_DK.UTF-8
LC_TELEPHONE=en_DK.UTF-8
LC_MEASUREMENT=en_DK.UTF-8
LC_IDENTIFICATION=en_DK.UTF-8

Is this the expected outcome of .CurrentUICulture and .CurrentCulture in this locale?

I would like the program to detect the current culture as Denmark, and parse ',' as a decimal separator, rather than a thousands separator.

Am I tripping over a known issue here? Is the default Culture always American unless I specifically ask the system for a preferred culture and set it?

SRNissen
  • 480
  • 9
  • Do you have libicu installed? – shingo Jun 03 '23 at 13:34
  • I have a bunch of different packages with approximately that name, most importantly probably `icu-devtools`, `libicu-dev` and `libicu70` – SRNissen Jun 03 '23 at 13:39
  • So it's installed, have you read this? https://stackoverflow.com/questions/19100708/mongodb-mongorestore-failure-localefacet-s-create-c-locale-name-not-valid – shingo Jun 03 '23 at 15:01

0 Answers0