Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
RVeitch_84
Creator
Creator

Convert from ASCII Text to HEX

I'm lookng for some help converting ASCII text to hex, I would like to do it in a tMap if possible.

Here is an example of my text string:

;7627

And here is the Hex equivalent:

3B37363237

Thanks for any help...

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

You can do this by creating a routine and calling the relevant method from that routine in the tMap. I had a quick Google to see if anyone had already written code for this and found this code....

 

String ascii = ";7627";

 

   // Step-1 - Convert ASCII string to char array

   char[] ch = ascii.toCharArray();

 

   // Step-2 Iterate over char array and cast each element to Integer.

   StringBuilder builder = new StringBuilder();

 

   for (char c : ch) {

     int i = (int) c;

     // Step-3 Convert integer value to hex using toHexString() method.

     builder.append(Integer.toHexString(i).toUpperCase());

   }

 

   System.out.println("ASCII = " + ascii);

   System.out.println("Hex = " + builder.toString());

 

..... here....

 

https://www.boraji.com/how-to-convert-ascii-to-hex-in-java

View solution in original post

1 Reply
Anonymous
Not applicable

You can do this by creating a routine and calling the relevant method from that routine in the tMap. I had a quick Google to see if anyone had already written code for this and found this code....

 

String ascii = ";7627";

 

   // Step-1 - Convert ASCII string to char array

   char[] ch = ascii.toCharArray();

 

   // Step-2 Iterate over char array and cast each element to Integer.

   StringBuilder builder = new StringBuilder();

 

   for (char c : ch) {

     int i = (int) c;

     // Step-3 Convert integer value to hex using toHexString() method.

     builder.append(Integer.toHexString(i).toUpperCase());

   }

 

   System.out.println("ASCII = " + ascii);

   System.out.println("Hex = " + builder.toString());

 

..... here....

 

https://www.boraji.com/how-to-convert-ascii-to-hex-in-java