ランダムな場所にヌル文字を含むchar配列があります。以下のように、この配列(encodedData_arr)を使用してiStringStreamを作成しようとしました。
このiStringStreamを使用して、バイナリデータ(Iplimageのimagedata)をMySQLデータベースblobフィールドに挿入します(MySQL Connector / C ++のsetBlob(istream * is)を使用)。最初のヌル文字までの文字のみを格納します。
ヌル文字を含むchar配列を使用してiStringStreamを作成する方法はありますか?
unsigned char *encodedData_arr = new unsigned char[data_vector_uchar->size()];
// Assign the data of vector<unsigned char> to the encodedData_arr
for (int i = 0; i < vec_size; ++i)
{
cout<< data_vector_uchar->at(i)<< " : "<< encodedData_arr[i]<<endl;
}
// Here the content of the encodedData_arr is same as the data_vector_uchar
// So char array is initializing fine.
istream *is = new istringstream((char*)encodedData_arr, istringstream::in || istringstream::binary);
prepStmt_insertImage->setBlob(1, is);
// Here only part of the data is stored in the database blob field (Upto the first null character)