sv-SE culture on RadzenNumeric gives wrong negative sign #762

Open
opened 2026-01-29 17:42:59 +00:00 by claunia · 0 comments
Owner

Originally created by @pierresetteskog on GitHub (Mar 7, 2023).

Ok second time I describe the bugg now Im know more exactly the problem
If you have swedish locale the negative sign differ from the english, I dont know why but it do.

  1. Go to https://localhost:44398/datafilter-odata
    image

  2. set sensors take random location and change Locale to "sv-SE"

  3. Filter on order id -1, notice directly after you leave the fields -1 is changed to a longer -
    4.gives following error from server: {"error":{"code":"","message":"The query specified in the URI is not valid. Syntax error: character '\u2212' is not valid at position 11 in 'OrderID eq \u22121'.","details":[],"innererror":{"message":"Syntax error: character '\u2212' is not valid at position 11 in 'OrderID eq \u22121'.","type":"Microsoft.OData.ODataException","stacktrace":" at Microsoft.OData.UriParser.ExpressionLexer.NextToken()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseComparison()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalAnd()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalOr()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpression()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpressionText(String expressionText)\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilterImplementation(String filter, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo)\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilter()\n at Microsoft.AspNet.OData.Query.FilterQueryOption.get_FilterClause()\n at Microsoft.AspNet.OData.Query.Validators.FilterQueryValidator.Validate(FilterQueryOption filterQueryOption, ODataValidationSettings settings)\n at Microsoft.AspNet.OData.Query.Validators.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings)\n at Microsoft.AspNet.OData.EnableQueryAttribute.ValidateQuery(HttpRequest request, ODataQueryOptions queryOptions)\n at Microsoft.AspNet.OData.EnableQueryAttribute.<>c__DisplayClass1_0.b__3(ODataQueryContext queryContext)\n at Microsoft.AspNet.OData.EnableQueryAttribute.ExecuteQuery(Object responseValue, IQueryable singleResultCollection, IWebApiActionDescriptor actionDescriptor, Func2 modelFunction, IWebApiRequestMessage request, Func2 createQueryOptionFunction)\n at Microsoft.AspNet.OData.EnableQueryAttribute.OnActionExecuted(Object responseValue, IQueryable singleResultCollection, IWebApiActionDescriptor actionDescriptor, IWebApiRequestMessage request, Func2 modelFunction, Func2 createQueryOptionFunction, Action1 createResponseAction, Action3 createErrorAction)"}}}

Expected behavior
desired behavior is to not change the negative sign to locale sign, like other frameworks. And always post numbers etc as invariant culture to server so OData dont fails

Additional context
Console.WriteLine($"sv: U+{(int)CultureInfo.GetCultureInfo("sv-SE").NumberFormat.NegativeSign.First():x4}");
Console.WriteLine($"en: U+{(int)CultureInfo.GetCultureInfo("en-US").NumberFormat.NegativeSign.First():x4}");
gives:
sv: U+2212
en: U+002d
swedish negative sign https://www.compart.com/en/unicode/U+2212
english negative sign https://www.compart.com/en/unicode/U+002D

I tried to fix it in the RadzenNumeric.Razor.cs with .Replace(CultureInfo.GetCultureInfo("sv-SE").NumberFormat.NegativeSign,"-"); but wrong char was still posted to the server. so probably a nicer solution is needed.

Workaround for swedish users in the blazor program.cs
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("sv-SE");
CultureInfo.DefaultThreadCurrentCulture.NumberFormat.NegativeSign = "-";
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.DefaultThreadCurrentCulture;
await builder.Build().RunAsync();

Originally created by @pierresetteskog on GitHub (Mar 7, 2023). Ok second time I describe the bugg now Im know more exactly the problem If you have swedish locale the negative sign differ from the english, I dont know why but it do. 1. Go to https://localhost:44398/datafilter-odata ![image](https://user-images.githubusercontent.com/4455363/223466681-db8778d5-f2f9-48e9-b82e-4b6d6929173a.png) 2. set sensors take random location and change Locale to "sv-SE" 3. Filter on order id -1, notice directly after you leave the fields -1 is changed to a longer - 4.gives following error from server: {"error":{"code":"","message":"The query specified in the URI is not valid. Syntax error: character '\u2212' is not valid at position 11 in 'OrderID eq \u22121'.","details":[],"innererror":{"message":"Syntax error: character '\u2212' is not valid at position 11 in 'OrderID eq \u22121'.","type":"Microsoft.OData.ODataException","stacktrace":" at Microsoft.OData.UriParser.ExpressionLexer.NextToken()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseComparison()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalAnd()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalOr()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpression()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpressionText(String expressionText)\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilterImplementation(String filter, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo)\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilter()\n at Microsoft.AspNet.OData.Query.FilterQueryOption.get_FilterClause()\n at Microsoft.AspNet.OData.Query.Validators.FilterQueryValidator.Validate(FilterQueryOption filterQueryOption, ODataValidationSettings settings)\n at Microsoft.AspNet.OData.Query.Validators.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings)\n at Microsoft.AspNet.OData.EnableQueryAttribute.ValidateQuery(HttpRequest request, ODataQueryOptions queryOptions)\n at Microsoft.AspNet.OData.EnableQueryAttribute.<>c__DisplayClass1_0.<OnActionExecuted>b__3(ODataQueryContext queryContext)\n at Microsoft.AspNet.OData.EnableQueryAttribute.ExecuteQuery(Object responseValue, IQueryable singleResultCollection, IWebApiActionDescriptor actionDescriptor, Func`2 modelFunction, IWebApiRequestMessage request, Func`2 createQueryOptionFunction)\n at Microsoft.AspNet.OData.EnableQueryAttribute.OnActionExecuted(Object responseValue, IQueryable singleResultCollection, IWebApiActionDescriptor actionDescriptor, IWebApiRequestMessage request, Func`2 modelFunction, Func`2 createQueryOptionFunction, Action`1 createResponseAction, Action`3 createErrorAction)"}}} **Expected behavior** desired behavior is to not change the negative sign to locale sign, like other frameworks. And always post numbers etc as invariant culture to server so OData dont fails **Additional context** Console.WriteLine($"sv: U+{(int)CultureInfo.GetCultureInfo("sv-SE").NumberFormat.NegativeSign.First():x4}"); Console.WriteLine($"en: U+{(int)CultureInfo.GetCultureInfo("en-US").NumberFormat.NegativeSign.First():x4}"); gives: sv: U+2212 en: U+002d swedish negative sign https://www.compart.com/en/unicode/U+2212 english negative sign https://www.compart.com/en/unicode/U+002D I tried to fix it in the RadzenNumeric.Razor.cs with .Replace(CultureInfo.GetCultureInfo("sv-SE").NumberFormat.NegativeSign,"-"); but wrong char was still posted to the server. so probably a nicer solution is needed. Workaround for swedish users in the blazor program.cs CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("sv-SE"); CultureInfo.DefaultThreadCurrentCulture.NumberFormat.NegativeSign = "-"; CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.DefaultThreadCurrentCulture; await builder.Build().RunAsync();
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#762