std::string test = "☺VERSION☺";
int result = test.find("☺");
//result always equals (-1) meaning it didnt find it
std::string and Unicode problem
Is it possible that std::string find() function will not recognize certain characters?
For example:
ok its formatting it into some WEIRD garbage here on the board, buts its a small smiley face type character....
thanks
Are you sure your giving us the exact code as above because this works:
All of those characters are in ascii character set, you don't need wstring unless you are going to use wide characters but i don't see that being the case.
#include <string>#include <iostream>int main() { std::string test("☺VERSION☺"), key("☺"); std::string::size_type result = test.find(key); if(result != std::string::npos) std::cout << "found at pos: " << result << ", word: " << test.substr(result, key.length()) << std::endl; else std::cout << "Not found" << std::endl; return 0;}
All of those characters are in ascii character set, you don't need wstring unless you are going to use wide characters but i don't see that being the case.
@snk_kid:
He's not trying to search for any of the characters in the ASCII string "☺". He's trying to search for the UNICODE character ☺, who's HTML entity is "☺". He formatted it that way for this forum.
He's not trying to search for any of the characters in the ASCII string "☺". He's trying to search for the UNICODE character ☺, who's HTML entity is "☺". He formatted it that way for this forum.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement