简体   繁体   中英

find_first_of for a unicode special character in a string by use of its byte

I'd like to do this, eg

size_t pos=wStr.find_first_of(L"U+8001");

But the gnu compiler keeps warning the character is too long. I don't know what character 0x8001 represents but that's its encoded byte.

Please try size_t pos=wStr.find_first_of(L"\老"); to search for the character U+8001.

Simplify your problem. Create a simple program, use the answer by MikeCAT, and prove to yourself that your wStr variable is correct and contains what you expect. For example...

std::wstring wStr(L"HELLO\u8001World");
auto aaa = wStr.find_first_of(L"\u8001");
std::cout << aaa;

You should also use the debugger, step to the location and look at the variable's contents.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM