<?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>topic Re: Convert hex data to ascii in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-convert-the-hex-data-into-ascii-without/m-p/621942#M216190</link>
    <description>&lt;P&gt;Sample log:&lt;/P&gt;&lt;P&gt;The attachment comes in hex and ascii. Wondering if it is possible to split the&amp;nbsp;AttachmentDetails field into ascii field and hex field&amp;nbsp;&lt;/P&gt;&lt;P&gt;Log1:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sender=test@test.com recipient=user@user.com subject='report 2023\\r\\n this is a\\r\\n test' AttachmentDetails={'report notes.pdf': {'BodyScanner': {}}}&lt;/LI-CODE&gt;&lt;P&gt;Log2:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sender=test@test.com recipient=user@user.com subject='report 2023\\r\\n this is a\\r\\n test' AttachmentDetails={'\x4e\x00\x4e\x8c\x4e\x09\x56\xdb.pdf': {'BodyScanner': {}}}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Nov 2022 05:52:19 GMT</pubDate>
    <dc:creator>xiaoming</dc:creator>
    <dc:date>2022-11-24T05:52:19Z</dc:date>
    <item>
      <title>Is it possible to convert the hex data into ascii without affecting the ascii data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-convert-the-hex-data-into-ascii-without/m-p/621525#M216039</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am attempting to convert data extracted as a field containing combination of hex and ascii data. Was wondering if it is possible to convert the hex data into ascii without affecting the ascii data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 12:08:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-convert-the-hex-data-into-ascii-without/m-p/621525#M216039</guid>
      <dc:creator>xiaoming</dc:creator>
      <dc:date>2022-11-21T12:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Convert hex data to ascii</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-convert-the-hex-data-into-ascii-without/m-p/621530#M216043</link>
      <description>&lt;P&gt;It depends if the hex data is delimited in some way. Can you share some anonymised examples (preferably in code block &amp;lt;/&amp;gt; format)?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 08:18:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-convert-the-hex-data-into-ascii-without/m-p/621530#M216043</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-21T08:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert hex data to ascii</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-convert-the-hex-data-into-ascii-without/m-p/621942#M216190</link>
      <description>&lt;P&gt;Sample log:&lt;/P&gt;&lt;P&gt;The attachment comes in hex and ascii. Wondering if it is possible to split the&amp;nbsp;AttachmentDetails field into ascii field and hex field&amp;nbsp;&lt;/P&gt;&lt;P&gt;Log1:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sender=test@test.com recipient=user@user.com subject='report 2023\\r\\n this is a\\r\\n test' AttachmentDetails={'report notes.pdf': {'BodyScanner': {}}}&lt;/LI-CODE&gt;&lt;P&gt;Log2:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sender=test@test.com recipient=user@user.com subject='report 2023\\r\\n this is a\\r\\n test' AttachmentDetails={'\x4e\x00\x4e\x8c\x4e\x09\x56\xdb.pdf': {'BodyScanner': {}}}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 05:52:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-convert-the-hex-data-into-ascii-without/m-p/621942#M216190</guid>
      <dc:creator>xiaoming</dc:creator>
      <dc:date>2022-11-24T05:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Convert hex data to ascii</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-convert-the-hex-data-into-ascii-without/m-p/621951#M216191</link>
      <description>&lt;P&gt;Here is a stab at converting what appears to be UCS2 - big endian Unicode CJK characters for 1234. U+4E00 U+4E8C, U+4E09, U+56DB&lt;/P&gt;&lt;P&gt;You can run this example.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval text="sender=test@test.com recipient=user@user.com subject='report 2023\\r\\n this is a\\r\\n test' AttachmentDetails={'\x4e\x00\x4e\x8c\x4e\x09\x56\xdb.pdf': {'BodyScanner': {}}}"
| rex field=text max_match=0 "\\\\x(?&amp;lt;c1&amp;gt;[0-9a-f]{2})\\\\x(?&amp;lt;c2&amp;gt;[0-9a-f]{2})"
| rex field=text max_match=0 "(?&amp;lt;unicode_hex&amp;gt;\\\\x[0-9a-f]{2}\\\\x[0-9a-f]{2})"
| eval c=mvzip(c1, c2, "")
| eval unicode_char=mvmap(c, printf("%c", tonumber(c, 16)))
| eval unicode_hex=mvmap(unicode_hex, replace(unicode_hex, "\\\\", "\\\\\\\\"))
| foreach 0 1 2 3 4 5 6 7 8 9 10 [ eval text_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=replace(text, mvindex(unicode_hex, &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;), mvindex(unicode_char, &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)),
                                        text=if(isnull(text_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;), text, text_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) 
                                   | fields - text_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; ]
| fields - c c1 c2 unicode_*&lt;/LI-CODE&gt;&lt;P&gt;this will parse out the \xx\yy pairs into the 16 bit chars (c) and then make their converted representation (printf).&lt;/P&gt;&lt;P&gt;It then makes a replacement map of the original pairs \xx\yy (it has to double the \ character to make the replace work).&lt;/P&gt;&lt;P&gt;The it will process up to 11 characters (foreach loop) to replace each \xx\yy sequence with the appropriate character.&lt;/P&gt;&lt;P&gt;This is a real hack, but functional - you can increase the foreach numbers to allow for as many as you need.&lt;/P&gt;&lt;P&gt;It converts to&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;sender=test@test.com recipient=user@user.com subject='report 2023\r\n this is a\r\n test' AttachmentDetails={'一二三四.pdf': {'BodyScanner': {}}}&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 07:21:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-convert-the-hex-data-into-ascii-without/m-p/621951#M216191</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-11-24T07:21:05Z</dc:date>
    </item>
  </channel>
</rss>

