--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
> This is using cx_Oracle and it works fine
> ===============================
>>>> cx_Oracle.version
> '5.0.3'
>>>> cursor.execute("select to_term from terminology_map where id=316")
>>>> cursor.fetchone()[0]
> 'Registro guardado con \xe9xito'
It's not clear to me which setting you used here. Was this using the
.UTF8 NLS_LANG as I requested? If so, then in fact this is also
coming back incorrectly, because that is not UTF-8. If not, then
we're comparing apples to oranges, since Django uses the .UTF8
setting.
Thanks,
Ian
Okay, so it would appear that the client encoding is not being honored
by Oracle for some reason. Just to verify that Django is setting it
correctly in the first place, would you please try the following in a
Django shell and let me know what you get?
>>> import os
>>> print os.environ['NLS_LANG']
>>> from django.db import connection
>>> connection.cursor() # Initialize the connection
>>> print os.environ['NLS_LANG']
>>> print connection.connection.encoding
>>> print connection.connection.nencoding
If everything is correct then the second NLS_LANG should be ".UTF8"
and both encodings should be "UTF-8". If that is the case then I
think your next step should be to try the cx_Oracle mailing list.
Perhaps Anthony or somebody else there will have some idea why
cx_Oracle or OCI are returning strings with the wrong encoding.
Otherwise, we will need to figure out why the client encoding is not
being set correctly by Django.
Ian
Weird. From what I can tell, this seems to have something to do with
Cygwin, or at least I'm able to replicate it in that environment.
Setting NLS_LANG in or out of process and changing the registry key
all have no effect.
Is there some reason you need to use Cygwin for this? Perhaps you
would have more luck with the regular win32 python.
Ian
The actual problem is described here:
http://rubyforge.org/forum/forum.php?thread_id=6826&forum_id=1078
and from the cx-oracle-users mailing list comes this suggestion:
>>> import ctypes
>>> ctypes.CDLL('kernel32').SetEnvironmentVariableA('NLS_LANG', '.UTF8')
I've tried it, and it works. I suggest patching the above into your
django/db/backends/oracle/base.py file, in place of the line:
os.environ['NLS_LANG'] = '.UTF8'
Cheers,
Ian
In your transcript, it appears that Django has already been loaded
when you call the ctypes code. The environment variable needs to be
set *before* cx_Oracle is imported by Django, or it won't have any
effect. This is why I suggested patching it into the
django/db/backends/oracle/base.py file.
Cheers,
Ian
You're welcome! I've checked a fix into trunk and the 1.2.X branch,
so future releases will not have this problem. I don't really see a
need for documentation apart from this thread on top of that.
Cheers,
Ian