strange behaviour of str()

2005-08-31 Thread Uwe Schmitt
> > Hello, > > I'm wondering about the following behaviour of str() with strings > containing non-ASCII characters: > > str(u'foo') returns 'foo' as expected. > > str('lää') returns 'lää' as expected. > > str(u'lää') raises UnicodeEncodeError > This does not work, because you need an encode

Re: strange behaviour of str()

2005-08-31 Thread Fredrik Lundh
Juho Vuori wrote: > str(u'lää') raises UnicodeEncodeError > Is this behaviour sane? Possibly, but not documented at all. str() on a Unicode string attempts to convert the string to an 8-bit string using Python's default encoding, which is ASCII. "ä" is not an ASCII character. if this problem a

strange behaviour of str()

2005-08-31 Thread Juho Vuori
Hello, I'm wondering about the following behaviour of str() with strings containing non-ASCII characters: str(u'foo') returns 'foo' as expected. str('lää') returns 'lää' as expected. str(u'lää') raises UnicodeEncodeError Is this behaviour sane? Possibly, but not documented at all. Somehow yo