Re: [cx-oracle-users] Issue with UTF-8 encoding
Brought to you by:
atuining
From: Guilherme M. <gui...@gm...> - 2010-11-18 16:24:00
|
Ok Anthony, thank you for answering. I guess I will continue to work using the WITH_UNICODE flag for now, since I am also using SqlAlchemy and thus I have no control over how strings are passed to cx_Oracle. Regards, Guilherme. On Thu, Nov 18, 2010 at 2:11 PM, Anthony Tuininga <ant...@gm...> wrote: > Hi, > > Yes, internally unicode objects are passed through to Oracle as UTF-16 > rather than encoding them in the encoding specified by NLS_LANG. You > can, of course, feel free to encode yourself but I understand that can > be a bit of a pain. I do have plans to see what the implications of > throwing away "Unicode" mode and any attempt to use UTF-16 and simply > encoding all strings as they are passed to Oracle -- but I have had no > time in the past few months. I'm hopeful that things might get a > little less crazy in the next few weeks.... > > Anthony > > On Wed, Nov 17, 2010 at 9:58 AM, Guilherme Menezes > <gui...@gm...> wrote: >> Hi, >> >> I am having an encoding issue using Python 2.6.2, cxOracle 5.0.4 to >> access an Oracle 11g database. >> >> I am using the NLS_LANG=.AL32UTF8 environment variable. My table in >> Oracle is correctly configured to accept Unicode. >> >> I compiled cxOracle without the WITH_UNICODE flag and passed unicode() >> objects to cxOracle. Everything worked without exceptions or warnings. >> However, sometimes Oracle would complain that the string I was trying >> to insert into a VARCHAR2 field was too big (> 4000), even when the >> string size ( len(the_string.encode('utf-8')) ) was about 2300 bytes. >> I used a sniffer to verify that the Oracle client was sending two >> bytes for each character (even the ASCII ones), instead of sending two >> bytes only for special characters. >> >> It seemed to me that cx_Oracle accepts unicode() objects but it does >> not encode() them to the correct encoding (as set in NLS_LANG >> variable) if the WITH_UNICODE flag is unset. Instead, it just sends to >> Oracle the internal representation of the unicode() object. >> >> Is this behaviour expected? Am I doing something wrong? >> >> Regards, >> >> Guilherme. >> >> ------------------------------------------------------------------------------ >> Beautiful is writing same markup. Internet Explorer 9 supports >> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. >> Spend less time writing and rewriting code and more time creating great >> experiences on the web. Be a part of the beta today >> http://p.sf.net/sfu/msIE9-sfdev2dev >> _______________________________________________ >> cx-oracle-users mailing list >> cx-...@li... >> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users >> > > ------------------------------------------------------------------------------ > Beautiful is writing same markup. Internet Explorer 9 supports > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. > Spend less time writing and rewriting code and more time creating great > experiences on the web. Be a part of the beta today > http://p.sf.net/sfu/msIE9-sfdev2dev > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |