@modoran: Interesting. I have never tried to stuff binary data into a std::string or std::wstring. Never even occurred the idea. If I have time, I'll try it out.
but I am getting the same result. It's like one of those terror movies, when the killer is always after you, doesn't matter what you do. I feel like if I put this
O.K. After almost going insane with this, I realized that my function was right. The problem has been located in another function. Just when I was about to give up.
Thanks to everyone. Boys, raise the sails! We are continuing our journey to the Isle of the Great Programmer
Your function is dimmed wrong from the start. You only get a pointer to first character returned, but you NEED buffer size also returned somewhat, you can't use strlen or any C functions to do that when dealing with binary data.
My std::string approach is doing all this for you and works without issues, I used myself in few projects.
Of course, you can't use any functions that expects a null terminated string like printf.
I made what webJose said in one of his replies here. Instead of returning a char* the function returns a struct that contains the char array and its size, so I can have them.