[freetds] tds_get_char_data and iconv

ZIGLIO Frediano Frediano.Ziglio at vodafoneomnitel.it
Fri May 2 04:55:33 EDT 2003

tds_get_char_data need some work. The caller know the "wire_size", so there's no reason to compute (there is also no good way to compute it...). tds_iconv call lead to buffer overflow (destination size is never decremented...). If we pass curcol there is no need to pass dest. IMHO a good prototype is:
  int tds_get_char_data(TDSSOCKET * tds, const TDSCOLINFO * curcol, int wire_size)
(if we want to discard data just call tds_get_n with NULL destination...)

iconv. This strange function is quite standard (present in solaris, hp/ux, linux, *bsd, mac os x...). However it's names aren't (as stated in many mail before). Consider iso8859-1 (this should be the standard name). 
Max OS X: ISO-8859-1 (do not accept ISO8859-1)
Solaris: 88591
HP/UX: iso88591
So there are no solution for all platform. IMHO configure should check all standard names using iconv command (not iconv function so it should work on cross compiler too).. Should we define some required charset ??
Another problem is conversions. GNU iconv accept conversion from any charset to any charset. Many implementation accept a limited conversion (for example in HP/UX I can convert iso88591 -> ucs2 and ucs2 -> iso88592 but it can't convert iso88591 -> iso88592). Samba solution is: if a direct conversion is not present convert to ucs2 first (GNU iconv internally convert chars to ucs4 and than ucs4 to destination charset)...


More information about the FreeTDS mailing list