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);
In reply to Re: XDR basic encode decode
by andal
in thread XDR basic encode decode
by mr0
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |