Changes between Version 6 and Version 7 of StringEncoding


Ignore:
Timestamp:
04/09/2007 05:57:24 AM (8 years ago)
Author:
mtredinnick
Comment:

Removed nonsense about DATABASE_CHARSET being needed. Turned out not to be true.

Legend:

Unmodified
Added
Removed
Modified
  • StringEncoding

    v6 v7  
    5858The 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.
    5959
    60 '''Proposal:''' All bytestrings used inside the Django core are assumed to be UTF-8 encoded.
     60'''New Convention:''' All bytestrings used inside the Django core are assumed to be UTF-8 encoded.
    6161
    6262Bytestrings 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.
     
    7070Django 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).
    7171
    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 
     72There 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 [4971] -- ''mtredinnick'')
    7673
    7774'''Proposal:''' For databases that support table creation with different collation or encoding schemes, add support in the existing DATABASE_OPTIONS setting for these.
Back to Top