title: Python - Encoding string - Swedish Letters
body: <p>I'm having some trouble with Python's raw_input command (Python2.6),
  For some reason, the raw_input does not get the converted string that swedify() produces and this giving me a encoding error which i'm aware of, that's why i made swedify() to begin with.
  Here's what i'm trying to do:</p>
  
  <pre><code>elif cmd in ('help', 'hjälp', 'info'):
      buffert += 'Just nu är programmet relativt begränsat,\nDe funktioner du har att använda är:\n'
      buffert += ' * historik :: skriver ut all din historik\n'
      buffert += ' * ändra &lt;något&gt; :: ändrar något i databasen, följande finns att ändra:\n'
      print swedify(buffert)
  </code></pre>
  
  <p>This works just fine, it outputs the swedish characters just as i want them to the console.
  But when i try to (in the same code, with same \x?? values, print this piece:</p>
  
  <pre><code>core['goalDistance'] = raw_input(swedify('Hur långt i kilometer är ditt mål: '))
  core['goalTime'] = raw_input(swedify('Vad är ditt mål i minuter att springa ' +  core['goalDistance'] + 'km på: '))
  </code></pre>
  
  <p>Then i get this:</p>
  
  <pre><code>C:\Users\Anon&gt;python löp.py
  Traceback (most recent call last):
    File "l÷p.py", line 92, in &lt;module&gt;
      core['goalDistance'] = raw_input(swedify('Hur l├Ñngt i kilometer ├ñr ditt m├Ñl: '))
  UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 5: ordinal not in range(128)
  </code></pre>
  
  <p>Now i've googled around, found some "solutions" but none of them work, some sad that i have to create a batch script that executes chcp ??? in the beginning, but that's not a clean solution IMO.</p>
  
  <p>Here is swedify:</p>
  
  <pre><code>def swedify(inp):
      try:
          return inp.decode('utf-8')
      except:
          return '(!Dec:) ' + str(inp)
  </code></pre>
  
  <p>Any solutions on how to get raw_input to read my return value from swedify()?
  i've tried from encodings import getencoder, getdecoder and others but nothing for the better.</p>