It is currently May 19th, 2022, 4:23 pm

[Bug?] String conversion of decimal numbers fails (esp. German)

Report bugs with the Rainmeter application and suggest features.
User avatar
SilverAzide
Rainmeter Sage
Posts: 1880
Joined: March 23rd, 2015, 5:26 pm

[Bug?] String conversion of decimal numbers fails (esp. German)

Post by SilverAzide »

Hello,

A user of one of my skins has reported an issue that appears to be a string-to-decimal conversion error due to internationalization. The user is using the German locale, in which the period is the thousands separator, and the comma is the decimal separator (e.g., "1.234,56"). Note the following measures (flagged in red):
Annotation 2022-03-27 132606.png

These are Registry measures, reading strings from the registry that are German-locale formatted decimal values. (If curious, these are the "raw" sensor values coming from HWiNFO, which outputs numeric values as strings formatted per the user's locale.)

It appears in this case that Rainmeter is not doing string-to-number conversion that is locale-aware. Is this known behavior, or is this a bug? I would have thought something like this would have cropped up long before now, so perhaps this is actually a quirk of the Registry measure. I've seen odd issues before with Registry measures, but not quite like this.

(A work-around for HWiNFO exists, in that it allows altering the separator values for the output.)
You do not have the required permissions to view the files attached to this post.
Gadgets Wiki GitHub More Gadgets...
User avatar
Yincognito
Rainmeter Sage
Posts: 4694
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Bug?] String conversion of decimal numbers fails (esp. German)

Post by Yincognito »

SilverAzide wrote: March 27th, 2022, 5:52 pm Hello,

A user of one of my skins has reported an issue that appears to be a string-to-decimal conversion error due to internationalization. The user is using the German locale, in which the period is the thousands separator, and the comma is the decimal separator (e.g., "1.234,56"). Note the following measures (flagged in red):

Annotation 2022-03-27 132606.png

These are Registry measures, reading strings from the registry that are German-locale formatted decimal values. (If curious, these are the "raw" sensor values coming from HWiNFO, which outputs numeric values as strings formatted per the user's locale.)

It appears in this case that Rainmeter is not doing string-to-number conversion that is locale-aware. Is this known behavior, or is this a bug? I would have thought something like this would have cropped up long before now, so perhaps this is actually a quirk of the Registry measure. I've seen odd issues before with Registry measures, but not quite like this.

(A work-around for HWiNFO exists, in that it allows altering the separator values for the output.)
Not sure if this is necessarily related to Registry measures (which in this case are typed as strings, though the manual says they are seamlessly converted to numbers as well), I see it as a way Rainmeter works (something that I very much agree with, personally I don't like my locale decimal system - identical to the one above - to be used in computer stuff, I hate it when MS Excel does that):

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[String]
Measure=String
String=1.258,8
RegExpSubstitute=1
Substitute="[.]":" ",",":"."," ":","

[Number]
Measure=String
String=[String]

---Meters---

[Text]
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text=String: [String]#CRLF#Number: [String:]#CRLF#Number: [Number:]
DynamicVariables=1
Maybe the basic idea is that the user should do the formatting as he likes in the displayed text from the meters? :confused:
User avatar
SilverAzide
Rainmeter Sage
Posts: 1880
Joined: March 23rd, 2015, 5:26 pm

Re: [Bug?] String conversion of decimal numbers fails (esp. German)

Post by SilverAzide »

Yincognito wrote: March 28th, 2022, 9:12 am Maybe the basic idea is that the user should do the formatting as he likes in the displayed text from the meters? :confused:
No, the point I am trying to make is not the display of the value in a meter, it is the internal numeric conversion in the Registry measure itself. If you look at the screenshot, "8,8" is being converted to the number 8, instead of 8.8. The screenshot was supplied by someone running Rainmeter in Germany, so I would expect that in that scenario the decimal point would be the comma, not the period.

As a separate issue, the numeric value is ALSO not being displayed properly either, but I've left that for a post later. For example, in a string meter, using Text="[SomeMeasure:3]" will output "1.234" when it should output "1,234".
Gadgets Wiki GitHub More Gadgets...
User avatar
Yincognito
Rainmeter Sage
Posts: 4694
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Bug?] String conversion of decimal numbers fails (esp. German)

Post by Yincognito »

SilverAzide wrote: March 28th, 2022, 1:18 pm No, the point I am trying to make is not the display of the value in a meter, it is the internal numeric conversion in the Registry measure itself. If you look at the screenshot, "8,8" is being converted to the number 8, instead of 8.8. The screenshot was supplied by someone running Rainmeter in Germany, so I would expect that in that scenario the decimal point would be the comma, not the period.

As a separate issue, the numeric value is ALSO not being displayed properly either, but I've left that for a post later. For example, in a string meter, using Text="[SomeMeasure:3]" will output "1.234" when it should output "1,234".
I perfectly understood you point the first time, don't worry.

For example, my perfmon.msc is displaying the % Processor Time counter value as 1,086 according to the regional settings in my case, but it's converted correctly to 1.086 by the UsageMonitor plugin when it comes to being used in Rainmeter. The Registry measure should do the same, of course, when it comes to your first paragraph.
PerfMonLocale.jpg
Not sure about your second paragraph though. In my view, Text="[SomeMeasure:3]" should always output "1.234" when it comes to Rainmeter, for various reasons like consistency across options and all that, letting the user format the output as he wants. I mean, the UsageMonitor plugin does the same for me, despite the identical regional settings (we also use comma as the decimal point where I live, by the way, and it's reflected in various Windows applications).

Example - I fully set my locale to my region:
PSLocale.jpg
However:

Code: Select all

[Variables]

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[String]
Measure=String
String=8,835
UpdateDivider=-1
DynamicVariables=1

[Number]
Measure=Calc
Formula=8.835
UpdateDivider=-1
DynamicVariables=1

---Meters---

[MeterTest]
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text="String = [String:]#CRLF#Number = [Number:3]"
UpdateDivider=-1
DynamicVariables=1
RainmeterLocale.jpg
I mean, unless I'm missing something here, that's the way Rainmeter always worked - it has never displayed Text="[SomeMeasure:3]" using comma as a decimal separator. Not even the UsageMonitor measures, which as I mentioned, correctly converts between the localized comma decimal separated values given by Windows / PerfMon to "platform agnostic" (so to speak) period separated values in Rainmeter, does that...
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Rainmeter Sage
Posts: 1880
Joined: March 23rd, 2015, 5:26 pm

Re: [Bug?] String conversion of decimal numbers fails (esp. German)

Post by SilverAzide »

OK... But UsageMonitor measures aren't a valid comparison with this issue. The raw perfmon data values are true numbers, not strings representing numbers, so there is no string-to-number conversion involved here.

As far as output is concerned, never having used Rainmeter in a different locale than my own, I am not familiar with the way Rainmeter would (or would not) output numeric values in localized formats.

It sounds like Rainmeter is not truly internationalized in some respects, which is fine, if that is the known and intended state.
Gadgets Wiki GitHub More Gadgets...
User avatar
Yincognito
Rainmeter Sage
Posts: 4694
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Bug?] String conversion of decimal numbers fails (esp. German)

Post by Yincognito »

SilverAzide wrote: March 28th, 2022, 5:35 pm OK... But UsageMonitor measures aren't a valid comparison with this issue. The raw perfmon data values are true numbers, not strings representing numbers, so there is no string-to-number conversion involved here.

As far as output is concerned, never having used Rainmeter in a different locale than my own, I am not familiar with the way Rainmeter would (or would not) output numeric values in localized formats.

It sounds like Rainmeter is not truly internationalized in some respects, which is fine, if that is the known and intended state.
Regarding UsageMonitor, you might be right - I was using it as a somewhat "similar" example, basically the only one I know or I could think of.

Yeah, I was only partly "localized" before (just the Additional Settings in Control Panel's Region section), but I went full for this test, checking the Administrative / Change System Locale there, as I was curious about it. Things being this way certainly explain the many threads on the forum about formatting numbers to the user preferences - I found some by jsmorley, but none in which he directly said that the period is used as a decimal separator, though it was more or less implied given the related subjects (they were more about the thousand separators, actually), just as it is implied in the Formulas page from the manual, where only the period is used. Maybe it wouldn't hurt to be said explicitly, to avoid any confusion, I don't know.