Hey there, where can I find a function to convert a hex string like “054C” into binary string like;
“0000010101001100”
I search the whole Google and found nothing. I got a Delphi function but I don’t know how to rewrite it in GO, below Delphi code;
function HexToBin(Hexadecimal: string): string;
const
  BCD: array [0..15] of string =
    ('0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111',
    '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111');
var
  I : integer;
begin
  for I := Length(Hexadecimal) downto 1 do
    Result := BCD[StrToInt('$' + Hexadecimal[i])] + Result;
end;And below my GO try, but I dunno how is that done in GO, I mean, the code line inside for loop;
func HexToBin(Hexadecimal string) string {
  var BCD = [16]string {
    "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111",
    "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"}
  var Rst string
  for I := len(Hexadecimal); I > 1; I-- {
    Rst = BCD[StrToInt('$' + Hexadecimal[i])] + Rst;
  }
}Could anyone help me with this line?
Rst = BCD[StrToInt('$' + Hexadecimal[i])] + Rst;Tnx.