How to test if a string has a certain unicode char?
- by Ruben Trancoso
Supose you have a command line executable that receives arguments. This executalbe is widechar ready and you want to test if one of this arguments starts with an HYPHEN case in which its an option:
command -o foo
how you could test it inside your code if you don't know the charset been used by the host?
Should be not possible to a given console to produce the same HYPHEN representation by another char in the widechar forest? (in such case it would be a wild char :P)
int _tmain(int argc, _TCHAR* argv[])
{
std::wstring inputFile(argv[1]);
if(inputFile->c_str() <is an HYPHEN>)
{
_tprintf(_T("First argument cannot be an option"));
}
}