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

Locale independence #146

Merged
merged 5 commits into from
Apr 8, 2017
Merged

Locale independence #146

merged 5 commits into from
Apr 8, 2017

Conversation

FSMaxB
Copy link
Collaborator

@FSMaxB FSMaxB commented Apr 8, 2017

This addresses #145.

Both parse_number and print_number weren't capable of handling locales where the decimal point is not '.'.

To fix this the current decimal-point is fetched via localeconv.

parse_number now parses the number into a buffer and replaces the '.' with the decimal-point character of the current locale.

print_number prints the number to a temporary buffer and then replaces the decimal-point with '.' when copying the number to the output. This also means that the size of the printed number is now known before space in the printbuffer is reserved, thereby loosening the space requirements for cJSON_PrintPreallocated.

FSMaxB added 5 commits April 8, 2017 02:41
This first prints the number into a temporary buffer and then copies the
number to the output.

A positive side effect is that cJSON no longer reserves more space for
the number in the output than is necessary.
@FSMaxB FSMaxB merged commit 74d0525 into master Apr 8, 2017
@FSMaxB FSMaxB deleted the locale-independence branch May 1, 2017 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants