note
Joost
Yup, C treats a 0 byte as the end of a string. And yes perl is written in C. However, perl strings are not C strings.
<p>
In C a string is nothing more than a pointer to the first character of the string. C can't know how long a string is except by counting all the characters from the start until the first 0 byte. You need to know the length of a string in order to do things like copy or compare them.
<p>
Perl's strings are C structs that include (amongst other things) a pointer to the first character, AND the length of the string. Since perl doesn't need a special terminating character you can use 0 characters in the middle of a string too.
<p>
Note that internally perl strings are still 0-terminated in order to facilitate interoperation with functions that expect C style strings. Also note that sending strings with embedded 0 characters to system calls or XS libraries does not always work as you'd expect, though all the buildin string and IO operations (regexes, print etc) should work correctly.
<p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-157432">
<em>[id://149675|"What should it profit a man, if he should win a flame war, yet lose his cool?"]</em>
</div></div>
555579
555579