monome / norns

norns is many sound instruments.
http://monome.org
GNU General Public License v3.0
633 stars 147 forks source link

replace / assess `string.char()` usage #1702

Closed catfact closed 1 year ago

catfact commented 1 year ago

rephrasing https://github.com/monome/norns/issues/1701 for more direct action, thanks @256k for bringing the problem to light.

in lua 5.3 at any rate, string.char(x, ... ) is i think technically undefined for x > 127; in practice it can produce a single-element non-ascii byte array which can lead to various problems for string rendering and transmission.

i think either string.char() should always have its arguments clamped to [0, 127], or should be replaced by utf8.char() which will always produce a legal C string at least.

a quick search reveals usages of string.char() in textentry and crow lua modules.