Re: [Mysql-cocoa-users] Bug with blob in framework or in my code ?
Brought to you by:
sergecohen
From: Eric V. <ev...@cl...> - 2007-02-04 10:38:49
|
The problem is solved (thanks to Hayden Stainsby) The data must be converted from hexa to NSData A new function "decodeBinaryData" may be very useful ! -------- - (NSMutableData*)decodeBinaryData:(NSData*)data { int i, theLength; const char *thumbnailHex; char *buffer; NSMutableData *thumbnailData =3D [[[NSMutableData alloc] init] = =20 autorelease]; thumbnailHex =3D [data bytes]; theLength =3D [data length]; buffer =3D (char *)calloc(sizeof(char),(theLength/2)); int index =3D 0; for (i =3D 0 ; i < theLength ; i +=3D 2) { char aByte, tChar[2]; =09 tChar[0] =3D thumbnailHex[i]; tChar[1] =3D thumbnailHex[i+1]; =09 tChar[0] -=3D 0x30; if (tChar[0] >=3D 0x0a) { tChar[0] -=3D 0x07; } =09 tChar[1] -=3D 0x30; if (tChar[1] >=3D 0x0a) { tChar[1] -=3D 0x07; } =09 =09 aByte =3D tChar[0] << 4; aByte =3D aByte | (tChar[1]); =09 buffer[index] =3D aByte; index++; } =09 [thumbnailData appendBytes:buffer length:(theLength/2)]; return thumbnailData; } Le 27 janv. 07 =E0 09:58, Eric VERDIN a =E9crit : > Hello, > > I try to save and read a picture in mysql. > I use the standard version (4.1.22 and 5.0.27 of mysql package) with > the same problem. > > ( http://sourceforge.net/mailarchive/forum.php? > thread_id=3D31463383&forum_id=3D2800 ) > > When i read the picture in mysql, the size is double ! > > Do you have the same problem (blob with utf8 ?) ? > > Any help would be most appreciated. > Thank you very much. > > Eric > > > ----------------------------------------------------------------------=20= > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to =20 > share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?=20 > page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV > _______________________________________________ > Mysql-cocoa-users mailing list > Mys...@li... > https://lists.sourceforge.net/lists/listinfo/mysql-cocoa-users > |