Hi Bill, thanks for the valuable inputs. I could hit a better solution
and I believe that is simplest one. Better, the solution is on the
application side and not on the DJango side.
What I did was this -
When my parser starts reading data from files (for which I don't know
the encoding), it first converts the URL information from the file in
to appropriate encoded values using iri_to_uri. Also, the encoding in
postgres database is set to utf-8 instead of default sql_ascii. This
setting in postgres creates another problem for psycopg2 connection,
so, whenever I create a connection object for psycopg2, i need to set
the encoding on the object. e.g. conn is my connection object, the
moment it is created, i do conn.set_client_encoding('utf-8'). The
things work fine thereafter.
The only change as compared previous implementation is, for those
special non-ascii characters, I see corresponding encoding in my
display (as %NN), in earlier implementation, I used to see the
characters as they were in the GUI.

One would question which one is a preferred method?
I would go with second one (changes on application side). In former
case, the story does not end there. If there is another component in
your application that needs to fetch data and process it (may be for
exporting to excel etc), you
have to handle that interface too, and keep on doing the same for
every new interface that you introduce. On the other hand, the changes
mentioned in this method ensure that we set proper encoding for the
data in the database so that all the components are comfortable in
processing the same.

I believe I should close this thread having found the appropriate
solution, still, comments/suggestions are welcome.

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to