Find string at UNICODE buffer using MEMCMP

unsigned char *buffer =NULL;
char findstring = "cplusplus"

buffer = function_to_ADD(starting_address, size)

/* in this buffer size 1500. all the data are UNICODE.

for(uint32_t i=0;i<size;i++)
{
if(0 == memcmp((char*)buffer,findstring,strlen(findstring )))
/*after some condition */
}

in this part buffer have unicode string. findstring is ASCII .

How to i convert ascii to uncode and find findstring in buffer.i do not know how to check?
can anyone help me?

Regards,
Kuluoz
Last edited on
you don't want to convert ascii to unicode.

first, findstring is a single character, which cannot hold a string, so that assignment is not legal and should fail.

second, you should be using c++ strings:
string findstring = "cplusplus";

to make string objects unicode, read this:

https://stackoverflow.com/questions/3010739/how-to-use-unicode-in-c

once you set up your strings for unicode, you can search them with string.find() and you can compare with == operations.

Memcpy and memcmp are best avoided unless deep inside a very low level high performance code block.


Topic archived. No new replies allowed.