Cyrillic letters.

Posts 1–5 of 5 · Page 1 of 1
Cyrillic letters.
Hello, i have to have a char *variable that is able to hold both English and Cyrillic letters.

This code works well.
Code:
char *s = "Example Title";
if(FindWindow(NULL, LPCSTR(s))) cout<<"Found."<<endl;
else cout<<"Not Found."<<endl;
but when i test a Cyrillic word like the code below, it doesn't work.
Code:
char *s = "Клиент";

I tried to use this, but it always prints "Found" even if there is no window called "Клиент".
Code:
char *s = "\0x41a\0x43b\0x438\0x435\0x43d\0x442" //"Клиент"
sorry for bad English.
msdn: http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
Code:
HWND WINAPI FindWindow(
  _In_opt_  LPCTSTR lpClassName,
  _In_opt_  LPCTSTR lpWindowName
);

http://social.msdn.microsoft.com/For...rum=vclanguage
Brian says:
Code:
LPSTR = char*
LPCSTR = const char*
LPWSTR = wchar_t*
LPCWSTR = const wchar_t*
LPTSTR = char* or wchar_t* depending on _UNICODE
LPCTSTR = const char* or const wchar_t* depending on _UNICODE
LPCTSTR = const char* or const wchar_t* depending on _UNICODE

const char * vs. const wchar_t*

I think by using LPCSTR, "if(FindWindow(NULL, LPCSTR(s)))", you forced a call to FindWindowA() instead of FindWindowW() (mentioned above)? maybe?

Try calling FindWindowW() explicitly as mentioned above.


"\0x41a\0x43b\0x438\0x435\0x43d\0x442" //"Клиент"

0x41a = 1050 , 0000 0100 0001 1010
0x43b = 1083 , 0000 0100 0011 1011
0x438 = 1080 , 0000 0100 0011 1000
0x435 = 1077 , 0000 0100 0011 0101
0x43d = 1085 , 0000 0100 0011 1101
0x442 = 1090 , 0000 0100 0100 0010

if it was calling FindWindowA(), it would try to interperet it as ascii
00000100 , 00011010 , 00000100 , 00111011 , 00000100 , 00111000 , 00000100 , 00110101 , 00000100, 00111101 , 00000100 , 01000010 .

00000100 is 4, which isn't a displayable character in ascii. Maybe that's causing FindWindowA() to bug? Just a guess really.
edit: googled ascii table and 4 is "EOT (end of transmission)". Probably not important, but made me lol. FindWindowA() could limit which characters are considered valid, but I'm not sure why it would return true :/

edit: I tried


and a few other things and couldn't get it to work. idk. disregard above text.
@abuckau907 Thanks for your reply, but it's not a solution ? or am i wrong ?
you are correct - I was just thinking out loud (and don't know C++/strings well enough).

I tried again and got...


Code:
int main()
{
	char* _appTitle = "Клиент";

	if (FindWindowW(NULL,L"Клиент"))
	{
		cout <<"aaa:window found" << endl;
	}
	else
	{
		cout <<"aaa: window not found" << endl;
	}

	if (FindWindowW(NULL,(LPCWSTR)_appTitle))
	{
		cout <<"zzz:window found" << endl;
	}
	else
	{
		cout <<"zzz:window not found" << endl;
	}






system("PAUSE");
return 0;
}


Code:
int main()
{
	LPWSTR _appTitle = L"Клиент";

	if (FindWindowW(NULL,L"Клиент"))
	{
		cout <<"aaa:window found" << endl;
	}
	else
	{
		cout <<"aaa: window not found" << endl;
	}

	if (FindWindowW(NULL,_appTitle))
	{
		cout <<"zzz:window found" << endl;
	}
	else
	{
		cout <<"zzz:window not found" << endl;
	}



system("PAUSE");
return 0;
}
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?