Bill de hÓra wrote: > gabor wrote: > >> so what do you think about the following approach: >> >> try ascii-decoding >> if fails, try utf8-decoding >> if fails do iso-8859-1-decoding (this cannot fail). >> >> ? > > Dumb question maybe. How do you know this encoding ladder will work?
it depends on how you define 'will work' :-) it will not fail (every string can be decoded as iso-8859-1). > >> but imho this should happen only in "special" cases like >> environ-variables.. for example in get/post params i would prefer to >> raise an exception when the data cannot be en/de-coded using the >> configured charset. > > You'd need to honor charset parameters sent out of Django apps and sent > back by the client. A sensible default encoding to emit is UTF-8. i would honor them if they would be sent :-) for example, using this html file: <form method="POST" action="http://localhost:7000"> <input type="text" name="gabor1" value="farkas1"/> </form> (+ additional xhtml-headers, http-equiv-content-type=utf-8 etc) firefox submits this: ============ POST / HTTP/1.1 Host: localhost:7000 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1b1) Gecko/20060601 BonEcho/2.0b1 (Ubuntu-edgy) Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: UTF-8,* Keep-Alive: 300 Connection: keep-alive Cookie: sessionid=9f5f5a5c387a07dd6b7e4d34a04e38b9 Content-Type: application/x-www-form-urlencoded Content-Length: 14 gabor1=farkas1 ============= so, in what charset is the POSTDATA? so, i agree with you, that if they do send it, we should honor it. but they are not sending it (i assume they should send it in the Content-Type header). the only usable assumption i have found up to now is that the browsers sends the data back encoded in the submitting-html-page's charset. or is there a better way? gabor --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers -~----------~----~----~----~------~----~------~--~---