Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Insert HEX value into buffer
#2
If you just try to import the string, you are getting the values of the characters. If you literally need the binary bytes represented by those two digit numbers, then you need to pull each two digit chunk out and convert to a hex value. If the format is consistently like that, then you could basically do this in a loop:

Code:
While (Index < FullStrLen)
     Card4Val := SrcStr.ExtractCard4R(Index, 2, Radices.Hex);
     TarBuf.PutCard1(OutBufIndex++, Card4Val.GetLowByte());
     Index += 3;
EndWhile;

So you loop through the string. Each time you extract a Hex digit. It will take the characters AA, for instance, and convert to the actual binary value 0xAA. You get a Card4 but only need a Card1, so get the low byte out, and put it into the next available index in the output buffer.

Then skip the string index forward by 3 to get to the next two digit chunk.

Once you get the whole buffer built up. Use the Base64 class to Base64 encode it, and that gets you the output format you want.
Dean Roddey
Explorans limites defectum
Reply


Messages In This Thread
Insert HEX value into buffer - by jnolting - 09-26-2018, 02:17 PM
RE: Insert HEX value into buffer - by Dean Roddey - 09-26-2018, 03:07 PM
RE: Insert HEX value into buffer - by jnolting - 09-27-2018, 08:10 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)