<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: HEX to String in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/hex-to-string/qaa-p/9374061#M3333949</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When dealing with some certificate data I've used an of_hextobyte method to convert hex data to a byte.&amp;nbsp; You could adapt that.&amp;nbsp; Just call in it a loop stepping through your string two characters at a time.&amp;nbsp; Think I may have borrowed this from PFC, but not sure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;char&amp;nbsp;&amp;nbsp;&amp;nbsp; lch_char[]&lt;/P&gt;&lt;P&gt;integer&amp;nbsp; li_byte&lt;/P&gt;&lt;P&gt;int li_dec[48 to 70], li_i, li_len&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//Get the decimal code for hexadecimal value of '0' to 'F'&lt;/P&gt;&lt;P&gt;// Whose ASC Value are from 48 to 57 and 65 to 70&lt;/P&gt;&lt;P&gt;For li_i = 48 To 57&lt;/P&gt;&lt;P&gt;&amp;nbsp; li_dec[li_i] = li_i - 48&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For li_i = 65 To 70&lt;/P&gt;&lt;P&gt;&amp;nbsp; li_dec[li_i] = li_i - 55&lt;/P&gt;&lt;P&gt;Next &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as_hex = upper(as_hex)&lt;/P&gt;&lt;P&gt;lch_char = as_hex&lt;/P&gt;&lt;P&gt;li_len = len (as_hex)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//Convert Hexadecimal data into decimal&lt;/P&gt;&lt;P&gt;For li_i = 1 to li_len&lt;/P&gt;&lt;P&gt;&amp;nbsp; //Make sure only 0's through f's are present&lt;/P&gt;&lt;P&gt;&amp;nbsp; Choose Case lch_char[li_i]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Case '0' to '9', 'A' to 'F'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; li_byte = li_byte * 16 + li_dec[asc(lch_char[li_i])]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Case Else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return li_byte&lt;/P&gt;&lt;P&gt;&amp;nbsp; End Choose&amp;nbsp; &lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Return li_byte&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Mar 2013 04:52:23 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2013-03-13T04:52:23Z</dc:date>
    <item>
      <title>HEX to String</title>
      <link>https://community.sap.com/t5/technology-q-a/hex-to-string/qaq-p/9374057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to convert a HEX to string for X509 certificate serial number. Anyone have a simple function for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Right now I'm using MS SQL Server to do the conversion but would love to do it client side.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT CONVERT(VARCHAR(MAX), CONVERT(VARBINARY(MAX), '0x3030303031303030303030323031303633393638', 1))&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-size: 10pt; font-family: Consolas;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;I'm using PB 12.5.1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Adrian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Mar 2013 23:49:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hex-to-string/qaq-p/9374057</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-03-12T23:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: HEX to String</title>
      <link>https://community.sap.com/t5/technology-q-a/hex-to-string/qaa-p/9374058#M3333946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sorry, Adrian, I'm not clear what data type variable you have that in, in PB. One would need that information to offer an answer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 00:00:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hex-to-string/qaa-p/9374058#M3333946</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-03-13T00:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: HEX to String</title>
      <link>https://community.sap.com/t5/technology-q-a/hex-to-string/qaa-p/9374059#M3333947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sorry. I'm calling an API that is returning a string with a HEX value. I need to convert that string with the HEX value to regular ascii string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I mention my first post I'm using a varchar on SQL Server to convert the varchar by only putting in front 0x so that SQL Server takes it as a HEX value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I use the following syntax PB will give me an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ls_hex = "~h"+ls_string &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Adrian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 01:13:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hex-to-string/qaa-p/9374059#M3333947</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-03-13T01:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: HEX to String</title>
      <link>https://community.sap.com/t5/technology-q-a/hex-to-string/qaa-p/9374060#M3333948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, Adrian, I'm still confused I'm afraid. A hex string is a string, and it is certainly ASCII. So what do you really mean? Do you mean convert a hex number (of how many digits?) to a long (perhaps very long?) integer, and then represent that as a string?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps you could give a simple specific example of what should be converted to what.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If others are clearer on this than I am, do jump in. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 01:34:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hex-to-string/qaa-p/9374060#M3333948</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-03-13T01:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: HEX to String</title>
      <link>https://community.sap.com/t5/technology-q-a/hex-to-string/qaa-p/9374061#M3333949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When dealing with some certificate data I've used an of_hextobyte method to convert hex data to a byte.&amp;nbsp; You could adapt that.&amp;nbsp; Just call in it a loop stepping through your string two characters at a time.&amp;nbsp; Think I may have borrowed this from PFC, but not sure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;char&amp;nbsp;&amp;nbsp;&amp;nbsp; lch_char[]&lt;/P&gt;&lt;P&gt;integer&amp;nbsp; li_byte&lt;/P&gt;&lt;P&gt;int li_dec[48 to 70], li_i, li_len&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//Get the decimal code for hexadecimal value of '0' to 'F'&lt;/P&gt;&lt;P&gt;// Whose ASC Value are from 48 to 57 and 65 to 70&lt;/P&gt;&lt;P&gt;For li_i = 48 To 57&lt;/P&gt;&lt;P&gt;&amp;nbsp; li_dec[li_i] = li_i - 48&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For li_i = 65 To 70&lt;/P&gt;&lt;P&gt;&amp;nbsp; li_dec[li_i] = li_i - 55&lt;/P&gt;&lt;P&gt;Next &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as_hex = upper(as_hex)&lt;/P&gt;&lt;P&gt;lch_char = as_hex&lt;/P&gt;&lt;P&gt;li_len = len (as_hex)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//Convert Hexadecimal data into decimal&lt;/P&gt;&lt;P&gt;For li_i = 1 to li_len&lt;/P&gt;&lt;P&gt;&amp;nbsp; //Make sure only 0's through f's are present&lt;/P&gt;&lt;P&gt;&amp;nbsp; Choose Case lch_char[li_i]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Case '0' to '9', 'A' to 'F'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; li_byte = li_byte * 16 + li_dec[asc(lch_char[li_i])]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Case Else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return li_byte&lt;/P&gt;&lt;P&gt;&amp;nbsp; End Choose&amp;nbsp; &lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Return li_byte&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Mar 2013 04:52:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hex-to-string/qaa-p/9374061#M3333949</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-03-13T04:52:23Z</dc:date>
    </item>
  </channel>
</rss>

