Why do linebreaks in text strings count as 2 characters and not 1?

Why do linebreaks in text strings count as 2 characters and not 1?

When i use Split (String) I have 2 empty slices per linebreak, yet if i use Strip (String EmptySlices) they are still there, meaning the 2 slices appear to be empty yet are not.

If i want to find where a linebreak occurs how can i find 2 slices that appear empty, yet aren’t.

Im confused… :/

what you’re seeing is that in windows a linebreak is made of two invisible characters: carriage-return and line-break. they have ascii codes 10 and 13 iirc. so you could look for those.

Enable Show Characters of IOBox (String) in Inspektor, should help “debugging”.

Thanks @joreg, that worked using AsRaw and AsValue (set to SByte) to look for values 10 and 13, with some Sift and DeleteSlice nodes to strip the linebreaks, but know where they were before. I’ve made a little subpatch that strips or replaces linebreaks in strings.

I have just come across something else really strange though:

If i pass a string to a Typospread, which has spaces or linebreaks in it, the binsize pin on typospread has a bug in that it shows binsizes for the spaces and linebreaks even though the points dont actually exist. If i do a spectral addition of the binsizes, surely it should be the same as the spreadcount i have specified!? Where is it taking the binary sizes from?

I just noticed this only happens if i change the string, making it all the more weird. I was just working on a small patch to show the bug, but when i saved and it reloaded it was back to normal. That makes it even more strange. I will attach the patch anyways. Just change the input string by adding or removing either a space or linebreak and see how the sum of binsizes goes up a lot.

@@bjoern: thank you, that does really help and i never noticed it before.

typospread_bin_bug.v4p (3.5 kB)

Reposting as bug.