Make output functions not null-terminated

As a Roblox developer it is currently too hard to debug code that involves placing the null character into strings, either through an accident or intentionally. This is because strings passed to things like print, warn, error, etc. are null-terminated, causing issues like this:

image

Instead of being null-terminated, the full value of the string should be outputted, with a visual indicator of some sort for null. This would make debugging cases like this easier by making it more visible when there was a problem.

If Roblox prevented things passed to the output from being null-terminated, it would improve my life as a developer. My life would further be improved if there was a visual indicator for null. I just spent the last several minutes wondering why Ma wasn’t equivalent to the same string with a null at the end because as far as I could see they were the same string. This was very frustrating and I would prefer it not happen again.

4 Likes

Support. One trick I’ve done in the past is to sub all occurrences of null with \0 or the empty string before printing, but it’d be nice for null to be handled better by default.

This is actually an issue with Lua 5.1. It has since been fixed in later versions of Lua, but in 5.1, print does not handle null characters properly. We’ve backported things from later versions of Lua before, so this is still something we might fix, but not via a change to the output widget.

1 Like

Ah, well that’s annoying. I suppose the feature request still stands though. I assumed it was an issue with the output widget because it applied to all of the output-interfacing functions, though it being an issue with the functions makes sense if they’re all mostly the same internally.