Re: newforms.CharField now returns unicode, but how to specify encoding?
On Fri, 2007-07-27 at 05:42 -0700, Gilbert Fine wrote: > I used django rev. 5559 for some time. After svn up today, I found > CharField's cleaned_data is unicode. I think it is a good idea. > Actually, I made this conversion in my source program. > > The only question is how to specify encoding of the string sent from > client browser? My users almost certainly using gb2312, not utf-8. This is documented in unicode.txt in the source. Online, it is at http://www.djangoproject.com/documentation/unicode/ although that may not be linked from the front documentation page yet (adding the doc file name after documentation/ is the pattern we use, though, so it's easy to guess -- an advantage of predictable URLs). If form submission is not in the default character set, it is up to you to set the encoding in your view function each time. However, we've given you the ability to do that for just the reason you mention. We don't do anything automatically (even with "accept-charset", since it's unreliably implemented and the browser doesn't always send the right information). Regards, Malcolm > > > Thanks. > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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-users?hl=en -~--~~~~--~~--~--~---
Re: newforms.CharField now returns unicode, but how to specify encoding?
Just as you said, all my html files are using utf-8. So it is OK at this time. But some part of our program needs to handle the data from other web site. That is, those forms are in some HTML pages (or programs) that we cannot control. They will use GB2312 encoding definitely. So we still need some way to specify char encoding in Form or CharField. -- Gilbert On Jul 27, 10:15 pm, Sam Morris <[EMAIL PROTECTED]> wrote: > On Fri, 27 Jul 2007 05:42:12 -0700, Gilbert Fine wrote: > > I used django rev. 5559 for some time. After svn up today, I found > > CharField's cleaned_data is unicode. I think it is a good idea. > > Actually, I made this conversion in my source program. > > > The only question is how to specify encoding of the string sent from > > client browser? My users almost certainly using gb2312, not utf-8. > > HTML4's description of the FORM element's 'accept-charset' attribute[0] > states: > > The default value for this attribute is the reserved string > "UNKNOWN". User agents may interpret this value as the character > encoding that was used to transmit the document containing this FORM > element. > > [0]http://www.w3.org/TR/html4/interact/forms.html#adef-accept-charset > > So, you can try specifying that you want the submitted data to be encoded > as utf-8 there, or you can serve the pages containing the FORM as utf-8 > and hope that the browser behaves sensibly and follows suite. > > -- > Sam Morrishttp://robots.org.uk/ > > PGP key id 1024D/5EA01078 > 3412 EA18 1277 354B 991B C869 B219 7FDB 5EA0 1078 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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-users?hl=en -~--~~~~--~~--~--~---
Re: newforms.CharField now returns unicode, but how to specify encoding?
On Fri, 27 Jul 2007 05:42:12 -0700, Gilbert Fine wrote: > I used django rev. 5559 for some time. After svn up today, I found > CharField's cleaned_data is unicode. I think it is a good idea. > Actually, I made this conversion in my source program. > > The only question is how to specify encoding of the string sent from > client browser? My users almost certainly using gb2312, not utf-8. HTML4's description of the FORM element's 'accept-charset' attribute[0] states: The default value for this attribute is the reserved string "UNKNOWN". User agents may interpret this value as the character encoding that was used to transmit the document containing this FORM element. [0] http://www.w3.org/TR/html4/interact/forms.html#adef-accept-charset So, you can try specifying that you want the submitted data to be encoded as utf-8 there, or you can serve the pages containing the FORM as utf-8 and hope that the browser behaves sensibly and follows suite. -- Sam Morris http://robots.org.uk/ PGP key id 1024D/5EA01078 3412 EA18 1277 354B 991B C869 B219 7FDB 5EA0 1078 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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-users?hl=en -~--~~~~--~~--~--~---
newforms.CharField now returns unicode, but how to specify encoding?
I used django rev. 5559 for some time. After svn up today, I found CharField's cleaned_data is unicode. I think it is a good idea. Actually, I made this conversion in my source program. The only question is how to specify encoding of the string sent from client browser? My users almost certainly using gb2312, not utf-8. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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-users?hl=en -~--~~~~--~~--~--~---