I have been trying to create a text file and code it in UTF-8. I have managed to do it using codecs
However, I am having trouble when I ask the user for input. Any ideas?

# -*- coding: cp1252 -*-
import codecs

fileName = "testing1"
textFile = codecs.open(fileName, "wt", encoding='utf-8')
variable = u"é "
foo=raw_input(u"what is your name: ")
textFile.write(u"héllo") #This works 
textFile.write(variable) #This works    
textFile.write(foo)# this fails
textFile.close()

Your code failed to execute with the strange "wt" mode, with "w" mode everything seemed to work in Python 2.7.3