https://bugzilla.novell.com/show_bug.cgi?id=456234

User [email protected] added comment
https://bugzilla.novell.com/show_bug.cgi?id=456234#c2


amc amc <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P5 - None                   |P3 - Medium
                 CC|                            |[email protected]
            Version|1.9                         |SVN




--- Comment #2 from amc amc <[email protected]>  2009-02-03 14:43:39 MST ---
current SVN (2.4, 2.2, 2.0,...) version of OdbcDataReader.GetValue() simply not
work with utf-8 strings >=255 bytes. i am updating bug version to SVN and hope
it is possible to apply previously attached fix as soon as possible. just in
case i copy-paste fixed version of code here:

case OdbcType.Text:
case OdbcType.VarChar:
    bufsize = (col.MaxLength < 255 ? (col.MaxLength+1) : 255);
    buffer = new byte[bufsize];  // According to sqlext.h, use SQL_CHAR for
both char and varchar
    StringBuilder sb1 = new StringBuilder ();
    char[] charBuffer = new char[bufsize];
    Decoder defaultDecoder = Encoding.Default.GetDecoder();
    do { 
        ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, buffer,
bufsize, ref outsize);
        if (ret == OdbcReturn.Error)
            break;
        // Fix for strance ODBC drivers (like psqlODBC)
        if (ret == OdbcReturn.Success && outsize==-1)
            ret = OdbcReturn.NoData;
        if (ret == OdbcReturn.Success || ret == OdbcReturn.SuccessWithInfo) {
            if (outsize >= bufsize || outsize ==
(int)OdbcLengthIndicator.NoTotal)
                outsize = bufsize - 1;
            int charCount = defaultDecoder.GetChars(buffer, 0, outsize,
charBuffer, 0);
            sb1.Append(charBuffer, 0, charCount);
        }
    } while (ret != OdbcReturn.NoData);
    DataValue = sb1.ToString ();
    break;

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to