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

Floating point values are converted with cultural settings #43

Open
tmm360 opened this issue Dec 29, 2016 · 4 comments
Open

Floating point values are converted with cultural settings #43

tmm360 opened this issue Dec 29, 2016 · 4 comments
Labels

Comments

@tmm360
Copy link

tmm360 commented Dec 29, 2016

For example, the double in some countries (as mine) is converted to string with a comma ',' instead of a dot '.' between integer and decimal digits, and encoding url it is converted to %2C.
This is an issue because decoding value first it is received as an array of two integers, and not in every context I can parse values before than they are decoded.

@darrelmiller
Copy link
Member

Thanks for the info. I'll look into it and try and include a fix in the next release.

@darrelmiller
Copy link
Member

The URI Template class handles strings, IEnumerable and IDictionary<string,string>. When the parameter is not one of those types, we simply call object.ToString(). Unfortunately, that method doesn't have a Culture property.  If we can identify which types need to be special cased, and that set of types covers a large enough set of cases, then we could add handling for that. However, this is a can of worms. I'm sort of wishing I had stuck with my original idea of requiring parameters to be explicitly converted to strings by the application before providing them to URI template.

@tmm360
Copy link
Author

tmm360 commented Jan 12, 2017

Actually I've solved applying this simple workaround to value value.ToString().Replace(',', '.'). You could handle floating point values, that at moment they are the only that are showing issues. Other value types with cultural settings don't occur to me...
I like very much capability of assign a simple value, library handles cases and perform mechanic normalizations, I don't like idea of have to convert values to string every time. It should be very painful. Thank you for your work!

@baywet
Copy link
Collaborator

baywet commented Jun 28, 2023

@darrelmiller we could start with all the number and date based types, that is:

  • datetime
  • datetimeoffset
  • timespan
  • numerics

by adding a switch expression based on type inference here

what do you think?

@baywet baywet added the bug label Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants