#Is there a cross platform newline?
1 messages · Page 1 of 1 (latest)
you can just make a utility constant, I'm fairly certain the only difference between platforms is that windows uses \r\n
yea I'd just do that
looks like std.log.* just uses \n in all cases, so I doubt there's anything in the standard library
i mean it's console
in files it's different
im tokenizing a file
windows can also have only \n tho...
if you're tokenising a file then I'd just have an optional \r before each \n
don't do it based on the platform
how do I do that lol
I don't know how you're tokenising the file so I can't say
yeah or that
std.mem.tokenizeAny(u8, buffer, &std.ascii.whitespace)
not all whitespace necessarily can be used as a delimeter
and also I think that would split twice on each newline on windows, like "a\r\nb" -> "a", "", "b"
that's split, tokenize skips empty
fair enough
std.mem.tokenizeAny(u8, buffer, "\r\n") should handle all three newline variants
ah true, should be only these two, not all whitespace
it's not really correct to hardcode an os-specific sequence when reading - there's no guarantee a file on that os will follow that convention