[Tutor] Unicode encoding and raw_input() in Python 2.7 ?
Alan Gauld
alan.gauld at btinternet.com
Fri Apr 17 21:58:10 CEST 2015
On 17/04/15 09:39, Samuel VISCAPI wrote:
> hello everyone !
Hello, and welcome.
> I've been stuck on a simple problem for the past few hours. I'd just
> like raw_input to work with accentuated characters.
>
> For example:
>
> firstname = str.capitalize(raw_input('First name: '))
>
> where firstname could be "Valérie", "Gisèle", "Honoré", etc...
>
> I tried -*- coding: utf-8 -*-, u'', unicode(), but to no avail...
You know what you tried. We don't so please post again showing
us some actual code that you tried and didn't work.
Tell us (or show us cut n pasted output) what you got and
what you expected.
Otherwise we are just guessing.
> I'm using str.capitalize and str.lower throughout my code, so I guess
> some encoding / decoding will also be necessary at some point.
capitalize/lower etc don't really care about encodings.
They just work with the string they are given.
I'm not sure what extra you think you will need to do.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list