title: How can I duplicate python 2 chr exactly in python 3
body: <p>Hi I am trying to migrate some code to python 3 but am having the following problem.</p>
  
  <p>Python 2</p>
  
  <pre><code>&gt;&gt;&gt; a = chr(217)
  &gt;&gt;&gt; print a, type(a)
  � &lt;type 'str'&gt;
  </code></pre>
  
  <p>Python 3</p>
  
  <pre><code>&gt;&gt;&gt; a = chr(217)
  &gt;&gt;&gt; print(a, type(a))
  Ù &lt;class 'str'&gt;
  </code></pre>
  
  <p>The reason is that I have Existing data created with the following code</p>
  
  <pre><code>from Crypto.Cipher import AES
  
  fle = open("data.dat", "wt")
  key = "password000*****"
  pwd = AES.new(key, AES.MODE_ECB)
  for dat in ("dataname001*****", "dataname002*****"):
      txt = ""
      hsh = pwd.encrypt(dat)
      for c in hsh:
          txt = txt + str(ord(c)) + ","
      fle.write("%s\n" % txt[:-1])
  fle.close()
  </code></pre>
  
  <p>I need to read the data which I can do using python2 but not python3</p>
  
  <pre><code>fle = open("data.dat", "rt")
  for dat in fle:
      txt = ""
      for c in dat.split(","):
          txt = txt + chr(int(c))
      print(pwd.decrypt(txt))
  </code></pre>