-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Usage of std::stof crashes on Windows when using some non-English languages/locales (i.e. German / de) #2221
Comments
Could usage be something like:
I did not managed to change my Windows locale into de even calling this |
Yes, usage like that should work! This should be the correct way to set locale actually: Here is an isolated example that can repro the same crash:
|
CC @marlenecota |
@bohdanprog / @marlenecota - Any progress on this bug? We need to update RNSVG for other bug fixes, and re-making the patch we need for this bug is becoming cumbersome. |
Bug
If the machine's locale is set to a language like German (de) or French (fr), rendering SVG paths that contain floating point numbers will crash if the floating point numbers use dots instead of commas as the radix. This is because languages like German expect the usage of commas in floating-point numbers (i.e. ",482" instead of ".482"), and
std::stof
takes into account the current locale of the application. PathView utilizesstd::stof
in its parsing logic.Fix recommendation:
std::from_chars
should be used instead as it will always use the C-default locale instead of whatever is currently set in the application. I have tested this locally and this seems to work as expected.Environment info
As far as I know, this reproduces on Windows 11 environments in react-native-svg version 13.14.0, and the latest 14.1.0.
Steps To Reproduce
Issues without reproduction steps or code are likely to stall.
PathView::UpdateProperties
viastd::setlocale(LC_ALL, "de_DE");
.d
property:"m41.213 20.483 6.8889 3.1408m0.48227-3.8605-7.3712 0.71964 7.2985 1.2256"
PathView::ParseNumber
during thestd::stof
call.Describe what you expected to happen:
Short, Self Contained, Correct (Compilable), Example
N/A
If more information is needed, please let me know.
The text was updated successfully, but these errors were encountered: