c++ - How to convert HEX to ASCII String? -


I have hex string and want to convert it to ASCII string in C / C ++. How do I complete it? Can i?

Unused status is loaded with #f Example: Digitally string 1234567 will be written in a field with 16 reserved positions (8 bytes).

hex 1 2 3 4 5 6 7fffffff

Input: 0x12 0x34 0x56 0x7f 0xff 0xff 0xff 0xff

Output: 1234567

shown in the example Encoding is BCD . That is, a byte can store up to 2 digits. Each digit is displayed by 4 bits if 4 bits are more than 1001 binary (9 decimals), then you want to explain that as an not-valid number , and I think That is to interpret FF hex as an empty space. You can use bitwire operators to access each nable in byte:

  // Assume that a byte of your input is stored as 'a' char a = 0x15 ; // It is 15 bcd / 3 lower lower and upper teasing characters low_nibble = a & amp; 0x0F; Char Upper_enbubble = (Another amp 0xF0) & gt; & Gt; 4; // Change to ASCII if (bottom_nuble> 9) low_nbabel = ''; // location and lower_enbabel = '0' + bottom_nubb; // Change to ASCII if (upper_nuble> 9) upper _nbabel = ''; // place and upper_nibal = '0' + upper enabl; // ASCII std :: cout and lt; & Lt; Change in "A \": "    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

jsp - Google line chart x-axis shrinks on transition -

java - Reaching JTextField in a DocumentListener -