Parsing Hex Strings
vegastech
Posts: 369
What is a recommended way to parse hex from a hex string? I am trying to do a remove_string where I remove the first byte of a 4 byte string, where it looks like this: ,$00,$04,$23,$D0. I want to remove each section and place it into its own array dimension, like so:
array[1] = ,$00 array[2] = ,$04 array[3] = ,$23 array[4] = ,$D0My goal here is to be able to ultimately calculate these hex values into decimal, and add them all together. However, the problem I am currently having is that when I try to do this:
local_var char sTesting[5] sTesting = (REMOVE_STRING(sProjInput,',',1))I get no response when I debug. I tried using the double quotes, which is what I am using to strip the first portion of the command response:
REMOVE_STRING(sProjInput,"$40,$03,$00,$0D",1)but I get a compiler error.
0
Comments
So in your situation, if you are simply wanting a string exploded into an array of individual character you don't actually have to do anything, you can simply use:
Hope this helps.
Much like a char. (char = 8bit, integer = 16bit ...)
So, let's say you have the following Hex String:
string: "$4E, $32, $8A, $0D"
You don't need a multidimensional array to store these values.
char copy_string[4]
copy_string[1] = string[1]
copy_string[2] = string[2]
copy_string[3] = string[3]
copy_string[4] = string[4]
You don't need to make a
char copy_string[4][2]
string to acommodate those Hex values