A
aine_canby
Hi,
Im totally new to Python so please bare with me.
Data is entered into my program using the folling code -
str = raw_input(command)
words = str.split()
for word in words:
word = unicode(word,'latin-1')
word.encode('utf8')
This gives an error:
File "C:\Python25\lib\encodings\cp850.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\x94' in
position 0
: character maps to <undefined>
but the following works.
str = raw_input(command)
words = str.split()
for word in words:
uni = u""
uni = unicode(word,'latin-1')
uni.encode('utf8')
so the problem is that I want replace my list with unicode variables.
Or maybe I should create a new list.
I also tried this:
for word in words[:]:
word = u""
word = unicode(word,'latin-1')
word.encode('utf8')
print word
but got TypeError: decoding Unicode is not supported.
What should I be doing?
Thanks for your help,
Aine.
Im totally new to Python so please bare with me.
Data is entered into my program using the folling code -
str = raw_input(command)
words = str.split()
for word in words:
word = unicode(word,'latin-1')
word.encode('utf8')
This gives an error:
File "C:\Python25\lib\encodings\cp850.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\x94' in
position 0
: character maps to <undefined>
but the following works.
str = raw_input(command)
words = str.split()
for word in words:
uni = u""
uni = unicode(word,'latin-1')
uni.encode('utf8')
so the problem is that I want replace my list with unicode variables.
Or maybe I should create a new list.
I also tried this:
for word in words[:]:
word = u""
word = unicode(word,'latin-1')
word.encode('utf8')
print word
but got TypeError: decoding Unicode is not supported.
What should I be doing?
Thanks for your help,
Aine.