You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building luau in a unity3d ilcpp project that internally use setlocale() to simulate c# locale.
Using some language setting like "fr" on the system strtod inside parseNumber is expecting ',' instead '.' and is throwing a "Manfolrmed number" error on float variables.
The text was updated successfully, but these errors were encountered:
I fixed it calling setlocale(LC_NUMERIC, "C"); because the rest of the project doesn't use any locale specific string parsing/formatting but I don't know if this was already discussed or can be a problem in other projects
This came up in #473 (fixed in #474) in context of CLI, with a similar fix. I think for now using C locale is the correct fix; correctly parsing numbers with C locale specification without doing that is pretty arduous (Lua tries to replace the dot with the decimal point but there are some potential inaccuracies with that approach wrt handling numbers that have a more complex formatting specification than just a different decimal point) - it might happen at some point but for now it's the best solution.
Except when luau is used in a program that manipulates locales in an unpredictable way. I ran into this issue when using luau in a LADSPA plugin (other LADSPA plugins are very fond of changing the locale), so setting the locale there from the start is not a solution. A workaround for me is to replace luai_str2num with a custom localeless implementation, but this source is not tested for number overflow. strtod.h
I also noticed that luau uses strtod directly in Ast/src/Parser.cpp:2101 not through a macro luai_str2num...
I'm building luau in a unity3d ilcpp project that internally use setlocale() to simulate c# locale.
Using some language setting like "fr" on the system strtod inside parseNumber is expecting ',' instead '.' and is throwing a "Manfolrmed number" error on float variables.
The text was updated successfully, but these errors were encountered: