|
|
| laziness, impatience, and hubris | |
| PerlMonks |
Align string on a 32-bit boundary with paddingby Lucas Rey (Sexton) |
| on Aug 18, 2022 at 09:26 UTC ( [id://11146218]=perlquestion: print w/replies, xml ) | Need Help?? |
|
Lucas Rey has asked for the wisdom of the Perl Monks concerning the following question:
Dear community, I'm just coding a little diameter avp converion and I need to pad the AVP string. According to RFC 3588, AVP string
that do not align on a 32-bit boundary MUST have the necessary padding 00. examples (space between values is only to shown better and should be removed on final string):
My simple code just takes a string and convert it in hex, but I need to add 00 padding on the right basing on above rules/example:
This will result in: STX2HEX: 6578616d706c652e6d65 10 So, final string should have 2 padding: 6578616d706c652e6d650000 Could someone help me to understand how to do that possibility without use any external module? Thank you Lucas
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||