hi,
i am not sure what exactly are you trying to do, here is what i did as a
quick test.
my config:
postgresql-8.0.
database created as UNICODE (which in case of postgres means utf8)
python-2.4
psycopg-1.1.18
django-0.90
i created a very simple application.
started the admin interface,
added text with japanese characters (kanji).
saved it
then opened it again, and it was ok.
i also checked in the database, and the text entered the database correctly.
i created a simple view, and checked the database contents from it.
the text is ok, and it is in non-unicode strings using the utf8
encoding. (so it is NOT in unicode-strings, but utf8-encoded byte-strings).
so a simple view can do for example:
def index(request):
event = events.get_list()[0]
title = event.title.decode('utf8')
//do something with title
bytestring = title.encode('utf8')
return HttpResponse(bytestring)
does this help?
bye,
gabor
why do you need this? dont you set the utf8 in the template/webpage
itself?
--
regards
kg
http://www.livejournal.com/users/lawgon
tally ho! http://avsap.org.in
ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!
?
:)
if i want to work with the title, i HAVE TO decode it, or not?
or is there a way to get unicode data directly from the database-layer?
gabor
not - you are doing all this over the web. If the template/webpage
has the correct setting it will happen automatically
well, maybe there is a misunderstanding.
i am not doing it over the web.
i am loading in data from the database.
please note, that in the part that you quoted, i am only doing:
1. read in data from the database into a bytestring
2. convert the bytestring into an unicode string
these steps have nothing to do with the webpage.
maybe you wanted to quote the other lines where i do the
unicode=>bytestring conversion?
gabor
Only thing I had added to my base template is:
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
Nothing else is/was needed.
--
Jeroen Ruigrok van der Werven
i understand you. but the code mr. Gonsales quoted did not do anything
with the webpage (at least it seemed to be). it only read something from
the db and that's all.
probably it's a misunderstanding.
about your dictionary project... you never went into unicode? you always
worked with utf8-encoded bytestrings? (just curious)
gabor