To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example parses an ASCII input string, removing the characters that aren't valid HEX characters, and then converts the remaining bytes into a binary string based on those HEX values.
Description
In some situations, you may need to use strings to describe a HEX value, but then need to convert that string into an arbitrary string which is that HEX value. This process is less intuitive then you may expect. Moreover, it is complicated to create a function that scales well and allows an arbitrary length of string to convert. This VI will take in any string and will parse the HEX characters from it, and then convert just those HEX values into a new string that is defined by those values. The resultant string is of an arbitrary length.
Requirements
Steps to Implement or Execute Code
Additional Information or References
VI Snippet
Note that the resultant string may include a zero hex value appended to the end if your input ASCII hex values do not translate into a multiple of 8 bits (for example, if you input 3 hex characters, the number of bits required to implement those values is 12, but an ASCII character is 8 bits, and so can only do multiples of 8. The resultant string will be 16 bits.)
A much simpler and more flexible implementation can be found in the following example.
Convert a String Which Describes a HEX Value to an Arbitrary String That is The HEX Value
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Thank you so much for this. It works great and has helped me tremendously.
Thank you for good information. I feel grateful to copy your information in other sites.