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'
In [1]: print('text\0A more text')
textA more text

In [2]: print(repr('text\0A more text'))
'text\x00A more text'
print | Modular Docs
printTs StringSlice[StaticConstantOrigin] = StringSlice("\0A"), flush FileDescriptor = FileDescriptor(1))
3 Replies
Lil'Nish
Lil'Nish3w ago
I think it's a typo. It probably means to say 0x0A (or 10 in base 10) which is ascii for the new line character \n
Chris Lattner
Chris Lattner2w ago
Interesting, it looks like a bug in the doc generation stuff not printing the escape character nicely, it actually defaults to "\n"
Stephen
StephenOP2w ago
Thanks Chris!

Did you find this page helpful?