title: Why emojis in Raw email are in Hexadecimal and how to decode it in Python
body: <p>We are working on a service that will parse a user's email. The following is a example of a raw email with emoji. This Hexadeciaml character in the email <code>=F0=9F=98=97</code> is an emoji . I could verified it from <a href="https://www.utf8-chartable.de/unicode-utf8-table.pl?start=128512" rel="nofollow noreferrer">here</a>.</p>
  <p>Why are the emojis coming this way? and is there any way to parse it in python3?</p>
  <p>I found a way to parse it with the help of bytes after manually removing the <code>=</code> symbols. It works.</p>
  <p><code>bytes.fromhex('F0 9F 99 82').decode('utf-8')</code></p>
  <p>Is there any other way to handle this in Python3?</p>
  <p>Thanks in advance</p>
  <p><strong>Example of a raw email:</strong></p>
  <pre><code>MIME-Version: 1.0
  Date: Wed, 22 Sep 2021 18:45:41 +0530
  References: &lt;CAFsQotqyCTbnR7ANDZX9oHYtHwtSf-im8pNj6N9pMXytbn+kbw@mail.gmail.com&gt;
  In-Reply-To: &lt;CAFsQotqyCTbnR7ANDZX9oHYtHwtSf-im8pNj6N9pMXytbn+kbw@mail.gmail.com&gt;
  Message-ID: &lt;CAAqby4THk2GSGbD-RXy5-6bwaEKHuBeWARMjUDRVvi+4_OTFVg@mail.gmail.com&gt;
  Subject: Re: wowoww
  From: email1 email1 &lt;email1@gmail.com&gt;
  To: email2 email2 &lt;email2@gmail.com&gt;
  Content-Type: multipart/related; boundary=&quot;000000000000a8da4205cc954fc4&quot;
  
  --000000000000a8da4205cc954fc4
  Content-Type: multipart/alternative; boundary=&quot;000000000000a8da4105cc954fc3&quot;
  
  --000000000000a8da4105cc954fc3
  Content-Type: text/plain; charset=&quot;UTF-8&quot;
  Content-Transfer-Encoding: quoted-printable
  
  AmsterDam
  
  On Tue, Aug 31, 2021 at 12:11 PM email1 email1 &lt;email2@gmail.com&gt;
  wrote:
  
  &gt; [image: unarchive.png]
  &gt; =F0=9F=99=82=E2=98=BA
  &gt; fsdfsdf
  &gt; sdf
  &gt; ds
  &gt; f
  &gt; sdf
  &gt; ds
  &gt; f
  &gt;
  &gt;
  &gt;
  
  --000000000000a8da4105cc954fc3
  Content-Type: text/html; charset=&quot;UTF-8&quot;
  Content-Transfer-Encoding: quoted-printable
  
  &lt;div dir=3D&quot;ltr&quot;&gt;AmsterDam&lt;br&gt;&lt;/div&gt;&lt;br&gt;&lt;div class=3D&quot;gmail_quote&quot;&gt;&lt;div dir=
  =3D&quot;ltr&quot; class=3D&quot;gmail_attr&quot;&gt;On Tue, Aug 31, 2021 at 12:11 PM email1 email1=
  i &amp;lt;&lt;a href=3D&quot;mailto:email2@gmail.com&quot;&gt;email2@gmail.com&lt;/a=
  &gt;&amp;gt; wrote:&lt;br&gt;&lt;/div&gt;&lt;blockquote class=3D&quot;gmail_quote&quot; style=3D&quot;margin:0px=
  0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex&quot;&gt;&lt;di=
  v dir=3D&quot;ltr&quot;&gt;&lt;img src=3D&quot;cid:ii_kszpbrxo0&quot; alt=3D&quot;unarchive.png&quot; width=3D&quot;=
  566&quot; height=3D&quot;283&quot;&gt;&lt;br&gt;&lt;div&gt;=F0=9F=99=82=E2=98=BA&lt;/div&gt;&lt;div&gt;fsdfsdf &lt;br&gt;&lt;/=
  div&gt;&lt;div&gt;sdf&lt;/div&gt;&lt;div&gt;ds&lt;/div&gt;&lt;div&gt;f&lt;/div&gt;&lt;div&gt;sdf&lt;/div&gt;&lt;div&gt;ds&lt;/div&gt;&lt;div&gt;=
  f&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;
  &lt;/blockquote&gt;&lt;/div&gt;
  
  --000000000000a8da4105cc954fc3--
  --000000000000a8da4205cc954fc4
  Content-Type: image/png; name=&quot;unarchive.png&quot;
  Content-Disposition: attachment; filename=&quot;unarchive.png&quot;
  Content-Transfer-Encoding: base64
  X-Attachment-Id: ii_kszpbrxo0
  Content-ID: &lt;ii_kszpbrxo0&gt;
  
  
  --000000000000a8da4205cc954fc4--
  </code></pre>