I was wondering if any of you could help me with a problem I'm having. Currently I have a function that takes in a c-style string, creates a temporary c++ style string and store the c string into it, and uses the find_first_not_of command to look for invalid characters, some of which include french characters like 'à'. However, when I pass in a string containing french characters, it doesn't recognize them as valid.
I am using visual studio 2013 on Windows 8, and a few people have told me that the issue is that how VS encodes it's files is different then how it encodes input from the command prompt, but I do not know how to fix that. Do any of you know how I would go about doing this? Or is is a different problem with my code entirely?
My code for the function is as follow:
bool checkValidCharacters(const char* input)
{
std::string checkString(input);
bool validCharacters = false;
std::size_t found = checkString.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZàâäèêëîôùûüÿçÀÂÄÈÉÊÎÏÔÙÛÜŸÇ-. ");
if (found != std::string::npos)
{
printf("Error: Invalid character: %c", input[found]);
}
else
{
printf("All characters valid\n");
validCharacters = true;
}
return validCharacters;
}
Thanks a bunch.