Log In  

Hello,

while trying to compact code to save tokens I ran into an issue when trying to use split with strings containing escaped numbers \0, \1, etc.. (to store binary data that will be converted with ord()

s="abc\0def ghijkl"
split(s," ")

This seems to stop at \0 and the string part after " " will not be in the resulting table.

Is this intended behavior or a bug? With other escaped characters as \n \r \t the splitting works fine.

If this could be possible it would help me save additional tokens.

Thank you,

TheRoboZ

P#98565 2021-10-13 02:27

:: GPI

"\0" is the "string-end-mark", so it seems, that split does what it should.

P#98572 2021-10-13 07:29

it does it with any number after \ and it's a bit inconsistent with the way you can use the string in ord() so I'd like a confirmation from @zep

P#98573 2021-10-13 07:43
1

\0 is no longer end string for unicode - so agree with TheRoboz that it should not stop

P#98575 2021-10-13 08:57
:: GPI
1

btw sub() seems to have a problem with /0 too

?sub("a\0b",1,1) --work
?sub("a\0b",2,2) -- dont work - output nothing
?sub("a\0b",1,3) --dont work - output nothing
?sub("a\0b",3,3) -- work

P#98602 2021-10-13 21:31 ( Edited 2021-10-13 21:33)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2021-10-20 13:51:20 | 0.009s | Q:14