title: python display unicode in html
body: <p>I'm writing script to export my links and their titles from chrome to html.<br>
  Chrome bookmarks stored as json, in utf encoding<br>
  Some titles are on Russian therefore they stored like that:<br>
  "name": "\u0425\u0430\u0431\u0440\ ..."</p>
  
  <pre><code>import codecs
  f = codecs.open("chrome.json","r", "utf-8")
  data = f.readlines()
  
  urls = [] # for links
  names = [] # for link titles
  
  ind = 0
  
  for i in data:
      if i.find('"url":') != -1:
          urls.append(i.split('"')[3])
          names.append(data[ind-2].split('"')[3])
      ind += 1
  
  fw = codecs.open("chrome.html","w","utf-8")
  fw.write("&lt;html&gt;&lt;body&gt;\n")
  for n in names:
      fw.write(n + '&lt;br&gt;')
      # print type(n) # this will return &lt;type 'unicode'&gt; for each url!
  fw.write("&lt;/body&gt;&lt;/html&gt;")
  </code></pre>
  
  <p>Now, in chrome.html I got those displayed as \u0425\u0430\u0431... <br>
  How I can turn them back to Russian? 
  <br>
  using python 2.5
  <br><br></p>
  
  <h2>**Edit: Solved!**</h2>
  
  <pre><code>s = '\u041f\u0440\u0438\u0432\u0435\u0442 world!'
  type(s)
  &lt;type 'str'&gt;
  
  print s.decode('raw-unicode-escape').encode('utf-8')
  Привет world!
  </code></pre>
  
  <p>That's what I needed, to convert <strong>str</strong> of \u041f... into <strong>unicode</strong>.</p>
  
  <pre><code>f = open("chrome.json", "r")
  data = f.readlines()
  f.close()
  
  urls = [] # for links
  names = [] # for link titles
  
  ind = 0
  
  for i in data:
      if i.find('"url":') != -1:
          urls.append(i.split('"')[3])
          names.append(data[ind-2].split('"')[3])
      ind += 1
  
  fw = open("chrome.html","w")
  fw.write("&lt;html&gt;&lt;body&gt;\n")
  for n in names:
      fw.write(n.decode('raw-unicode-escape').encode('utf-8') + '&lt;br&gt;')
  fw.write("&lt;/body&gt;&lt;/html&gt;")
  </code></pre>