Skip to content Skip to sidebar Skip to footer

How To Use Hextobin In Delphi Firemonkey For Android

I'm trying to adopt some Windows code to Android, but I am unsuccessful. When I try to compile the following code, I get an error: [DCC Error] There is no overloaded version of 'H

Solution 1:

For Android you have to use one of these overloads:

functionHexToBin(const Text: PChar; TextOffset: Integer;
  var Buffer: TBytes; BufOffset: Integer; Count: Integer): Integer; overload;

functionHexToBin(const Text: TBytes; TextOffset: Integer;
  var Buffer: TBytes; BufOffset: Integer; Count: Integer): Integer; overload;

You can best achieve this by using a TBytesStream instead of a TMemoryStream.

A valid call could then look like this:

var
  BinaryStream: TBytesStream;
  bytes: TBytes;
  HexStr: String;
begin
  HexStr := memo1.Text;
  SetLength(bytes, Length(HexStr) div2);
  HexToBin(PWideChar(HexStr), 0, bytes, 0, Length(bytes));
  BinaryStream := TBytesStream.Create(bytes);
  ...

Post a Comment for "How To Use Hextobin In Delphi Firemonkey For Android"