ModularM
Modular13mo ago
5 replies
Stephen

Why is `"\0A"` the default `end` value for `print`?

I saw this in some hover text in vscode and wondered if that was correct. Sure enough the docs confirm this.

I sort of understand the null termination, but why the 'A' after the null byte?

In the future, can we expect print to handle null bytes?

e.g., in python, I can do

In [1]: print('text\0A more text')
textA more text

In [2]: print(repr('text\0A more text'))
'text\x00A more text'
printTs StringSlice[StaticConstantOrigin] = StringSlice("\0A"), flush FileDescriptor = FileDescriptor(1))
print | Modular Docs
Was this page helpful?