|
@@ -62,11 +62,11 @@ Type
|
|
|
Function Encode(const aBuffer : AnsiString; doPad : Boolean = True) : AnsiString; overload;
|
|
|
// Decode aSrcBuffer with length aLen.
|
|
|
// Buffer must have enough room. Calculate maximum needed room with GetDecodeLen
|
|
|
- Function Decode(const aSrcBuffer : PByte; aLen : Integer; ABuffer : PByte) : Integer; virtual; overload;
|
|
|
+ Function Decode(const aSrcBuffer : PByte; aLen : Integer; ABuffer : PByte; SkipWhiteSpace : Boolean = True) : Integer; virtual; overload;
|
|
|
// Buffer must have enough room. Calculate maximum needed room with GetDecodeLen
|
|
|
- Function Decode(const S : AnsiString; ABuffer : PByte) : Integer; overload;
|
|
|
+ Function Decode(const S : AnsiString; ABuffer : PByte; SkipWhiteSpace : Boolean = True) : Integer; overload;
|
|
|
// Return a buffer with decoded data.
|
|
|
- Function Decode(const S : AnsiString) : TBytes; overload;
|
|
|
+ Function Decode(const S : AnsiString; SkipWhiteSpace : Boolean = True) : TBytes; overload;
|
|
|
// Return a buffer with decoded data, starting with buffer.
|
|
|
Function Decode(const aBuffer: PByte; aLen : Integer) : TBytes; overload;
|
|
|
// Get a decoding length for the encoded string S. May be oversized due to padding.
|
|
@@ -209,7 +209,10 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Function TAlphabetEncoder.Decode(const aSrcBuffer : PByte; aLen : Integer; ABuffer : PByte) : Integer;
|
|
|
+Function TAlphabetEncoder.Decode(const aSrcBuffer : PByte; aLen : Integer; ABuffer : PByte;SkipWhiteSpace : Boolean = True) : Integer;
|
|
|
+
|
|
|
+Const
|
|
|
+ WhiteSpace = [Ord(' '),10,13,9];
|
|
|
|
|
|
var
|
|
|
i, Reg, lBits : Integer;
|
|
@@ -224,8 +227,19 @@ begin
|
|
|
if Alen=0 then exit;
|
|
|
pSrc:=@aSrcBuffer[0];
|
|
|
pDest:=aBuffer;
|
|
|
- for i:=1 to aLen do
|
|
|
+ I:=1;
|
|
|
+ While (i<=aLen) do
|
|
|
begin
|
|
|
+ if SkipWhiteSpace then
|
|
|
+ begin
|
|
|
+ While (PSrc^ in WhiteSpace) and (I<=aLen) do
|
|
|
+ begin
|
|
|
+ Inc(PSrc);
|
|
|
+ Inc(I);
|
|
|
+ end;
|
|
|
+ if I>aLen then
|
|
|
+ break;
|
|
|
+ end;
|
|
|
if Reverse[pSrc^] <= 0 then
|
|
|
break;
|
|
|
Reg:=Reg shl Bits;
|
|
@@ -238,6 +252,7 @@ begin
|
|
|
inc(pDest);
|
|
|
end;
|
|
|
inc(pSrc);
|
|
|
+ Inc(i);
|
|
|
end;
|
|
|
Result:=pDest-aBuffer;
|
|
|
end;
|
|
@@ -250,12 +265,12 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-function TAlphabetEncoder.Decode(const S: AnsiString): TBytes;
|
|
|
+function TAlphabetEncoder.Decode(const S: AnsiString; SkipWhiteSpace : Boolean = True): TBytes;
|
|
|
|
|
|
begin
|
|
|
Result:=[];
|
|
|
SetLength(Result,GetDecodeLen(S));
|
|
|
- SetLength(Result,Decode(S,PByte(Result)));
|
|
|
+ SetLength(Result,Decode(S,PByte(Result),SkipWhiteSpace));
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -268,10 +283,10 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Function TAlphabetEncoder.Decode(const S : AnsiString; ABuffer : PByte) : Integer; overload;
|
|
|
+Function TAlphabetEncoder.Decode(const S : AnsiString; ABuffer : PByte;SkipWhiteSpace : Boolean = True) : Integer; overload;
|
|
|
|
|
|
begin
|
|
|
- Result:=Decode(PByte(S),Length(S),ABuffer);
|
|
|
+ Result:=Decode(PByte(S),Length(S),ABuffer,SkipWhiteSpace);
|
|
|
end;
|
|
|
|
|
|
|