lbrandewie has asked for the wisdom of the Perl Monks concerning the following question:
Hey folks,
I'm having a problem. I'm porting some perl to C to speed it up, and I can't get the two languages to agree on what's going on. I'm using ActiveState's perl 5.24.1 for Windows. Consider the following code:
$test = "\n\n\n\n\n";
for ($x = 0; $x < length($test); $x++) {
print ord(substr($test, $x, 1));
<STDIN>;
}
The code prints a string of 10s, indicating that the 13/10 combination in Windows has been translated to a bare 10. I can understand that, for compatibility reasons. But it seems to mean there is no way in Windows of telling a 13/10 combo from a bare 10. This makes a difference in my code, in that I can't get C and perl to hash the same string the same way. Am I missing something? Is there no way at all to tell a 13/10 from a 10 in Windows perl?
I believe the upshot of this, where my code is concerned, is that perl is doing it "wrong" compared to C and I'll never get the two to agree. I hope I'm wrong about that. I note with interest and mild annoyance that strlen("\n") == 1 even in C for windows. But C allows me to get at the underlying character buffer and perl does not.
Thanks,
Lars
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl to C problem
by haukex (Archbishop) on Feb 16, 2019 at 06:47 UTC | |
|
Re: Perl to C problem
by Athanasius (Archbishop) on Feb 16, 2019 at 07:09 UTC | |
by lbrandewie (Acolyte) on Feb 16, 2019 at 18:10 UTC |