in reply to XDR basic encode decode
Perl's pack() and unpack() offer partial solutions: the "N" format delivers a good fit (4 byte uint in network byte-order), but "A/*" encodes a string without extending the byte string payload length up to a multiple of 4-bytes.
Have you tried something like
my $l = length($string); $l += 3; $l >>= 2; $l <<= 2; pack("a$l", $string);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XDR basic encode decode
by mr0 (Initiate) on Mar 27, 2012 at 09:20 UTC |