Re: [cx-oracle-users] Antw: Bad conversion of a unicode value?
Brought to you by:
atuining
From: Anthony T. <ant...@gm...> - 2007-11-29 15:46:20
|
Well, imagine my surprise to return after a short trip to find a dozen messages, including patches! :-) As I've said before, I'm happy to accept patches and I'll certainly look at this one. I have some questions that would help me understand further what you are trying to accomplish. I'm only slowly beginning to get my head around Unicode -- the concept is very simple but the implementations are many and varied... :-( 1) You used OCIEnvNlsCreate() but then specified 0 for both the charset and the ncharset which implies that you're not gaining anything by using it? Did you try this just using the normal OCIEnvCreate()? 2) You set the OCI_ATTR_CHARSET_FORM but I am already doing that in (for example) StringVar.c. Did you remove it from that location? Are there more changes that you haven't specified? Perhaps it will all become clear when I look at it further. Hopefully I'll get a chance to look at it today yet. What would be very helpful is a set of SQL statements and Python code that clearly demonstrate the problem and then applying the patch clearly removes that problem. I might be able to piece things together from the maelstrom of e-mails that were sent in the past couple of days but one clear summarizing e-mail would be very helpful. :-) I'll then use that information for the basis of a test case as well. On Nov 28, 2007 8:31 AM, Michael Schlenker <ms...@co...> wrote: > Michael Schlenker schrieb: > > matilda matilda schrieb: > >>>>> Michael Schlenker <ms...@co...> 28.11.2007 12:13 >>> > >>> So i think cx_Oracle somehow mistakenly converts to database encoding= somewhere in between. > >> Hi Michael, > >> > >> I'm not sure if this is a problem of cx_Oracle. That's the reason I wr= ote this little > >> Embedded C Program for that. On the C level I only get byte sequences = anyway. So, I'm > >> sure that nothing but the Oracle client library is in between (hopeful= ly ;-)). > >> > Okay, i got my test to work after patching cx_Oracle a little bit. > > From taking a closer look at the code Unicode support is at best to be d= escribed as > 'rudimentary', lots of fine points still missing in there. > > With that patch (against the cx_Oracle-4.3.3.zip file) at least my test r= uns through > cleanly when i set the right environment. One surely can do better.... > > > Michael > > -- > Michael Schlenker > Software Engineer > > CONTACT Software GmbH Tel.: +49 (421) 20153-80 > Wiener Stra=DFe 1-3 Fax: +49 (421) 20153-41 > 28359 Bremen > http://www.contact.de/ E-Mail: ms...@co... > > Sitz der Gesellschaft: Bremen | Gesch=E4ftsf=FChrer: Karl Heinz Zachries > Eingetragen im Handelsregister des Amtsgerichts Bremen unter HRB 13215 > > diff -u5 cx_Oracle-4.3.3/Environment.c cx_Oracle-4.3.3_patched/Environmen= t.c > --- cx_Oracle-4.3.3/Environment.c 2007-10-02 05:46:58.000000000 +02= 00 > +++ cx_Oracle-4.3.3_patched/Environment.c 2007-11-28 15:26:15.33905= 3700 +0100 > @@ -83,12 +83,12 @@ > mode =3D OCI_OBJECT; > if (threaded) > mode |=3D OCI_THREADED; > > // create the environment handle > - status =3D OCIEnvCreate(&environment->handle, mode, NULL, NULL, > - NULL, NULL, 0, NULL); > + status =3D OCIEnvNlsCreate(&environment->handle, mode, NULL, NULL, > + NULL, NULL, 0, NULL,0,0); > if (!environment->handle) { > Py_DECREF(environment); > PyErr_SetString(PyExc_RuntimeError, > "Unable to acquire Oracle environment handle"); > return NULL; > Only in cx_Oracle-4.3.3_patched: Environment.c~ > diff -u5 cx_Oracle-4.3.3/Variable.c cx_Oracle-4.3.3_patched/Variable.c > --- cx_Oracle-4.3.3/Variable.c 2007-10-02 05:46:58.000000000 +0200 > +++ cx_Oracle-4.3.3_patched/Variable.c 2007-11-28 16:27:31.292026100 +01= 00 > @@ -445,10 +445,11 @@ > case SQLT_LNG: > return &vt_LongString; > case SQLT_AFC: > return &vt_FixedChar; > case SQLT_CHR: > + case SQLT_VCS: > if (charsetForm =3D=3D SQLCS_NCHAR) > return &vt_NationalCharString; > return &vt_String; > case SQLT_RDD: > return &vt_Rowid; > @@ -669,11 +670,11 @@ > if (Environment_CheckForError(cursor->environment, status, > "Variable_Define(): data type") < 0) > return NULL; > > // retrieve character set form of the parameter > - if (dataType !=3D SQLT_CHR && dataType !=3D SQLT_CLOB) { > + if (dataType !=3D SQLT_CHR && dataType !=3D SQLT_VCS && dataType != =3D SQLT_CLOB) { > charsetForm =3D SQLCS_IMPLICIT; > } else { > status =3D OCIAttrGet(param, OCI_HTYPE_DESCRIBE, (dvoid*) &chars= etForm, > 0, OCI_ATTR_CHARSET_FORM, cursor->environment->errorHand= le); > if (Environment_CheckForError(cursor->environment, status, > @@ -736,10 +737,20 @@ > "Variable_Define(): define") < 0) { > Py_DECREF(var); > return NULL; > } > > + status =3D OCIAttrSet((void *)var->defineHandle, > + (ub4) OCI_HTYPE_DEFINE, (void *) &var->type->charsetForm, > + (ub4) 0, (ub4)OCI_ATTR_CHARSET_FORM, > + cursor->environment->errorHandle); > + if (Environment_CheckForError(var->environment, status, > + "Variable_Define(): attr_charset_form") < 0) { > + Py_DECREF(var); > + return NULL; > + } > + > // call the procedure to set values after define > if (var->type->postDefineProc) { > if ((*var->type->postDefineProc)(var) < 0) { > Py_DECREF(var); > return NULL; > @@ -831,11 +842,11 @@ > "Variable_InternalBind(): set charset form") < 0) > return -1; > } > > // set the max data size for strings > - if ((var->type =3D=3D &vt_String || var->type =3D=3D &vt_FixedChar) > + if ((var->type =3D=3D &vt_String || var->type =3D=3D &vt_FixedChar |= | var->type =3D=3D &vt_NationalCharString) > && var->maxLength > var->type->elementLength) { > status =3D OCIAttrSet(var->bindHandle, OCI_HTYPE_BIND, > (dvoid*) &var->type->elementLength, 0, OCI_ATTR_MAXDATA_= SIZE, > var->environment->errorHandle); > if (Environment_CheckForError(var->environment, status, > > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: The Future of Linux Business White Paper > from Novell. From the desktop to the data center, Linux is going > mainstream. Let it simplify your IT future. > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > |