I've read more than once the "unicode on python 2.7 how-to" and browsed this forum thoroughly, but nothing I found and tried makes my program work.
It's supposed to convert dictionary.com entries into sets of example sentences and also word-pronunciation pairs. Yet it fails at the very start: the IPA (i.e. unicode) characters are converted into gibberish right after they're entered.
# -*- coding: utf-8 -*-
""" HERE'S HOW A TYPICAL DICTIONARY.COM ENTRY LOOKS LIKE
white·wash
/ˈʰwaɪtˌwɒʃ, -ˌwɔʃ, ˈwaɪt-/ Show Spelled
noun
1.
a composition, as of lime and water or of whiting, size, and water, used for whitening walls, woodwork, etc.
2.
anything, as deceptive words or actions, used to cover up or gloss over faults, errors, or wrongdoings, or absolve a wrongdoer from blame.
3.
Sports Informal. a defeat in which the loser fails to score.
verb (used with object)
4.
to whiten with whitewash.
5.
to cover up or gloss over the faults or errors of; absolve from blame.
6.
Sports Informal. to defeat by keeping the opponent from scoring: The home team whitewashed the visitors eight to nothing.
"""
def wdefinp(): #word definition input
wdef=u''
emptylines=0
print '\nREADY\n\n'
while True:
cinp=raw_input() #current input line
if cinp=='':
emptylines += 1
if emptylines >= 3: #breaking out by 3xEnter
wdef=wdef[:-2]
return wdef
else:
emptylines = 0
wdef=wdef + '\n' + cinp
return wdef
wdef=wdefinp()
print wdef.decode('utf-8')
this yields: white·wash /�ʰwaɪtˌwɒ�, -ˌwɔ�, �waɪt-/ Show Spelled ...
Any help will be appreciated.