Allow padding of strings by setting a MinLength when converting to bytes
parent
7568688c97
commit
b38f2b6cef
|
@ -20,6 +20,9 @@ namespace LANCommander.PowerShell.Cmdlets
|
|||
[Parameter]
|
||||
public int MaxLength { get; set; } = 0;
|
||||
|
||||
[Parameter]
|
||||
public int MinLength { get; set; } = 0;
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
byte[] output;
|
||||
|
@ -27,6 +30,11 @@ namespace LANCommander.PowerShell.Cmdlets
|
|||
if (MaxLength > 0 && Input.Length > MaxLength)
|
||||
Input = Input.Substring(0, MaxLength);
|
||||
|
||||
if (MinLength > 0 && MinLength < MaxLength)
|
||||
Input = Input.PadRight(MinLength, '\0');
|
||||
else if (MinLength > 0)
|
||||
Input = Input.PadRight(MaxLength, '\0');
|
||||
|
||||
if (Utf16 && BigEndian)
|
||||
output = System.Text.Encoding.BigEndianUnicode.GetBytes(Input);
|
||||
else if (Utf16)
|
||||
|
|
Loading…
Reference in New Issue