c++ - Performing string operations on data that might contain null \0 -


i'm implementing pluggable mime filter ie (this question concerns iinternetprotocol::read(void*, ulong, ulong*)) , i'm intercepting incoming html view modify html.

the html generally utf-8 encoded, except there \0 (null) characters, , sits inside char buffer. want load inside std::string instance can perform string operations such std::string::find inserting content (by copying substrings destination buffer around injected string, this:

string received( this->buffer ); size_t index = received.find("<p id=\"foo\">"); if( index != string::npos ) {      memcpy( destination             , received              , index );     memcpy( destination + index     , "injected content"    ,    17 );     memcpy( destination + index + 17, received.substr(index), received.size() - 17 - index ); } else {     memcpy( destination             , this->buffer          , this->buffersize ); } 

the problem buffer might contain null bytes (it's quirk of website i'm working with). extent \0 character values interact string operations such find? documentation on msdn nor cplusplus.com not say.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -