title: Python: handling non-Ascii characters in a Google Picasa feed
body: <p>I'm working on a Python script to sync Google Photos/Picasa with a local folder (on Mac). Each album on Picasa = a local folder.</p>
  
  <p>Some of my album titles have non-Ascii characters in them, and I cannot work out how to properly compare these album titles with the local folder names. A match is never found, and so the local folder is always deleted and then recreated. Can anyone help me solve this?</p>
  
  <p>The code below shows my current script, including my attempt to convert album titles and folder names to unicode, which I thought would be the answer:</p>
  
  <pre><code>import os
  import gdata.photos.service
  
  username = 'mattbarr99'
  target = '/Users/home/Desktop/GooglePhotos/'
  
  gd_client = gdata.photos.service.PhotosService()
  
  # get Google album titles
  google_albums = gd_client.GetUserFeed(user=username)
  google_album_titles = [unicode(album.title.text, 'utf-8') for album in google_albums.entry]
  
  # check local folders
  for entry in os.listdir(target):
      if not os.path.isdir(os.path.join(target, entry)):
          continue
      if unicode(entry, 'utf-8') not in google_album_titles:
          print "removing local folder: %s" % unicode(entry, 'utf-8')
          os.rmdir(os.path.join(target, entry))
  
  # check Google albums
  for album in google_albums.entry:
      local_album_path = os.path.join(target, album.title.text)
      if not os.path.exists(local_album_path):
          print "creating local folder: %s" % local_album_path
          os.mkdir(local_album_path)
  </code></pre>
  
  <p>The print out that I see when running the script is always:</p>
  
  <pre><code>removing local folder: Aspö 2015
  creating local folder: /Users/home/Desktop/GooglePhotos/Aspö 2015
  </code></pre>
  
  <p>I'm assuming that the problem is text encoding, and that I just don't know the right way to handle it. I hope I've provided enough information: this is my first post on stack overflow. Any help much appreciated!</p>