openresty / luajit2

OpenResty's Branch of LuaJIT 2
https://luajit.org/luajit.html
Other
1.2k stars 193 forks source link

Localization broken when printing numeric values #126

Open lerbec4 opened 3 years ago

lerbec4 commented 3 years ago

The function that converts numeric values to a string uses a hardcoded decimal separator ('.'). The problem is this breaks localization for locales that use a comma for the decimal separator. This can be reproduced using the following Lua script:

os.setlocale("fr_FR")
print(1.5)

This prints the following:

1.5

However, this should print:

1,5
piotrp commented 3 years ago

It's by design: https://github.com/LuaJIT/LuaJIT/issues/673

Direct links to documentation: https://luajit.org/extensions.html#tostring, https://luajit.org/extensions.html#tonumber