One problem though is that Lua is also not source code compatible between platforms. It has three sources of problems in this regard because of the use of locale-aware functions:
- ctype, to check if a character is a letter.
- sprintf, to convert numbers to strings.
- strtod, to convert strings to numbers.
Code: Select all
os.setlocale('fra_fra')
print(1.5) -- prints 1,5 (notice the comma)
print(tonumber('1.5')) -- prints nil because the conversion fails
print('1.5' + 0) -- crashes with a stack trace because the conversion fails
Although I never faced a problem caused by locale, I can't help but think a player of my game could face problems because his OS has a locale where the decimal separator is a comma.
So the questions are: Have you ever faced a locale-based problem with Lua/LÖVE? What the above code outputs on your system if you remove the os.setlocale line?
Cheers,
Andre