-
Notifications
You must be signed in to change notification settings - Fork 72
Fixed decimal for Scandinavian and similar Culture #105
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
Conversation
Scandinavian and some other regions use Comma (,) instead of Period (.) for decimal places. This causes some issues when entering float values, so this fixes it by just replacing the comma.
ManlyMarco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does the comma come from? Rather than replacing it, the better way would be to fix whatever is producing it. I would guess it's some conversion that is missing StringConverter.InvariantCulture in its parameters.
From what I could gather, it's due to the .ToString() when converting from floats/double to string. I tried adding this check and it has the same result. It's just a lot more code. // Original code
// var strVal = value.ToString().AppendZeroIfFloat(setting.SettingType);
// My change
var strVal = "";
if (setting.SettingType == typeof(float))
{
strVal = ((float)value).ToString(nfi);
}
else if (setting.SettingType == typeof(double))
{
strVal = ((double)value).ToString(nfi);
}
else if (setting.SettingType == typeof(decimal))
{
strVal = ((decimal)value).ToString(nfi);
}
strVal = strVal.AppendZeroIfFloat(setting.SettingType);I can update the PR if this solution is more favorable. |
|
Just do |
object.ToString() does not have any overload functions, meaning the example you are stating, does not exist. The issue with that is in the function private void DrawUnknownField(SettingEntryBase setting, int rightColumnWidth) at the line I have updated the PR, is this an acceptable solution? |
ManlyMarco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks.
Scandinavian and some other regions use Comma (,) instead of Period (.) for decimal places. This causes some issues when entering float values. (cherry picked from commit 1ca4951)
Scandinavian and some other regions use Comma (,) instead of Period (.) for decimal places.

This causes some issues when entering float values, by the values going haywire and jumping all over the place.
This simple fix just replaces the comma with a period and seems to fix the issue.
NOTE: I have only tried this with Danish Culture, so there might be some issue with other cultures I haven't happened upon.