How to test if a string has a certain unicode char?
Posted
by Ruben Trancoso
on Stack Overflow
See other posts from Stack Overflow
or by Ruben Trancoso
Published on 2010-06-05T07:19:25Z
Indexed on
2010/06/05
7:22 UTC
Read the original article
Hit count: 194
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"));
}
}
© Stack Overflow or respective owner