HEX string generating - extreme fast

Share your advanced PureBasic knowledge/code with the community.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: HEX string generating - extreme fast

Post by wilbert »

swhite wrote:I would be helpful to have a PokeH() function as well that takes a Hex string and converts it to the binary ascii values. :)
There should be code on the forum like that.
What's important in this case is to decide if validation of the input is required.
If you know for sure that the input only contains hex characters, conversion can be done a lot faster compared to having to check each character and stop the conversion when a non hex character is encountered.
Windows (x64)
Raspberry Pi OS (Arm64)
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: HEX string generating - extreme fast

Post by Little John »

wilbert wrote:
swhite wrote:I would be helpful to have a PokeH() function as well that takes a Hex string and converts it to the binary ascii values. :)
There should be code on the forum like that.
I have posted functions PeekHexBytes() and PokeHexBytes() more than 9 years ago. :-)
That thread also contains code by other forum members.
wilbert wrote:What's important in this case is to decide if validation of the input is required.
If you know for sure that the input only contains hex characters, conversion can be done a lot faster compared to having to check each character and stop the conversion when a non hex character is encountered.
Both above mentioned functions are not optimized for speed, but written with safety and versatility in mind (however, I tried not to slow them down unnecessarily). This means that PokeHexBytes() does validate its input.
Post Reply