On Jan 28, 2:02 pm, "ak" <[EMAIL PROTECTED]> wrote:
> Bjorn, if you read my first messages and specially my patch #3370, you
> find that I made a suggestion that if the guys want to move to unicode
> they better drop all native encodings support and so does my patch.
You mean require all I/O edge/boundary points to convert to/from
Python unicode strings? (We'll of course need to support non-UTF
character encodings in databases, files, the web, etc.)
> Then people started to answer me that this is wrong. And at the moment
> noone is able to explain the whole thing and answer my quesions:
> 1. how do they want to support templates and python code (views/
> scripts) in native encodings if django itself would be all in unicode.
> The only way i see is to encode/decode everything at programmer's end
> and this means for me no native encodings support at all.
Support for Unicode strings (u"") in code is described in PEP-263,
e.g.,
#!/usr/bin/python
# -*- coding: <encoding name> -*-
Unfortunately it's not implemented yet (AFAIK), so you can't just have
unescaped literals:
s = u"encoded text goes here" # doesn't work yet; pending
PEP-263
An alternative for literals in code is to surround them with unicode()
and specify the appropriate encoding:
s = unicode("encoded text goes here", "encoding name")
An even better way is to externalize all strings in .po files and use
gettext, which has some support for returning unicode strings.
I guess templates could have their character encoding identified
either through a similar mechanism, through a global settings
variable, or just use the system default encoding.
> 2. how do they want to support legacy databases if db connection speaks
> unicode
I'm not sure I can follow you. How to configure a database adapter
depends on the database and adapter you're using. Some can accept
unicode strings; for those that don't I guess you'll need a wrapper of
some sort.
Rgds,
Bjorn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---