F
Frank Nielsen
Can istrstream contain binary data like '\0' and other non ascii characters????
My program received a byte array through jni (java) and i must put it in a stream to continue the flow in the program, but i am unable to succeed this STL problem. Below is a little sample that should show my problem...
const char* data1 = "hej1";
const char* data2 = "hej2";
char data[10];
memcpy( &data[0], data1, 5 );
memcpy( &data[5], data2, 5 );
int len = 10;
std::istrstream isb( data );
std:strstream osb;
osb << isb;
printf( "len = %i\n", osb.pcount() );
printf( "str = %s\n", osb.str() );
Output is:
len = 8 (where does it get this number from?????)
str = 0012FE24????????????????????????²²²²??????
I expected:
len = 10
str = hej1
Are there any solution to my fustrations????
My program received a byte array through jni (java) and i must put it in a stream to continue the flow in the program, but i am unable to succeed this STL problem. Below is a little sample that should show my problem...
const char* data1 = "hej1";
const char* data2 = "hej2";
char data[10];
memcpy( &data[0], data1, 5 );
memcpy( &data[5], data2, 5 );
int len = 10;
std::istrstream isb( data );
std:strstream osb;
osb << isb;
printf( "len = %i\n", osb.pcount() );
printf( "str = %s\n", osb.str() );
Output is:
len = 8 (where does it get this number from?????)
str = 0012FE24????????????????????????²²²²??????
I expected:
len = 10
str = hej1
Are there any solution to my fustrations????