Changes between Version 6 and Version 7 of StringEncoding
- 04/09/2007 05:57:24 AM (9 years ago)
v6 v7 58 58 The only potential problem here is when bytestrings are passed between Django and the developer's code. Once again, we have no way of knowing the encoding. Most of the time, the two parties should exchange unicode strings. When bytestrings are passed, we need to have a convention about how these strings are encoded. This is a case where we cannot enforce (at the Python level) any requirement. We can only say "here is what Django expects" and if a developer does not respect this, any errors are their own to deal with. 59 59 60 ''' Proposal:''' All bytestrings used inside the Django core are assumed to be UTF-8 encoded. 60 ''':''' All bytestrings used inside the Django core are assumed to be UTF-8 encoded. 61 61 62 62 Bytestrings passed between the core and the applications should not be dependent on the encoding of the source files they were created in (those files using [http://www.python.org/dev/peps/pep-0263/ PEP 263] encoding declarations). PEP 263 does not do anything special to bytestrings. It parses them, but leaves them with their original encoding. That encoding information is lost as soon as the string moves beyond its original source file. … … 70 70 Django will need to encode all strings it sends to the database with the right encoding method. Similarly, all incoming strings needs to be decoded to unicode objects (keeping them as bytestrings will lose the information about the database encoding, which may not always be UTF-8). 71 71 72 '''Proposal:''' Add a new setting to django called DATABASE_CHARSET which is used to database encoding and decoding. This setting contains a string that is understood by Python's ''codecs'' module, not necessarily by the database server. 73 74 There is currently no way in Django to have the database encoding be any different from the HTML output encoding. We need to fix this. 75 72 There is currently no way in Django to have the database encoding be any different from the HTML output encoding. We need to fix this (this has been fixed in  -- ''mtredinnick'') 76 73 77 74 '''Proposal:''' For databases that support table creation with different collation or encoding schemes, add support in the existing DATABASE_OPTIONS setting for these.