Consider the following code snippet (in Delphi XE2):
function PrepData(StrVal: string; Base64Val: AnsiString): OleVariant;
begin
Result := VarArrayCreate([0, 1], varVariant);
Result[0] := StrVal;
Result[1] := Base64Val;
end;
Base64Val
is a binary value encoded as Base64 (so no null
bytes). The (OleVariant
) Result is automatically marshalled and sent between a client app and a DataSnap server.
When I capture the traffic with Wireshark, I see that both StrVal
and Base64Val
are transferred as Unicode strings. If I can, I would like to avoid the Unicode conversion for Base64Val
. I've looked at all the Variant
types and don't see anything other than varString
that can transfer an array of characters.
I found this question that shows how to create a variant array of bytes. I'm thinking that I could use this technique instead of using an AnsiString
. I'm curious though, is there another way to assign an array of non-Unicode character data to a Variant without a conversion to a Unicode string?