Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

hello..

i'm developing phone book manager.

input : text file
parse : cut string by white characters and conver it wide string

i need to check whether the token string is valid.

now..wstrDataCurr indicates url:test.com

my code doesn't work (cannot compare "url").
i don't know...why it doesn't work..T.T

could you tell me...what is the problem...?

followings are part of my code.

while(*wstrDataCurr)
{
switch(*wstrDataCurr)
{
case (WCHAR *)'t':
case (WCHAR *)'u':
case (WCHAR *)'n':
if( WSTRNICMP((WCHAR *)"tel" , wstrDataCurr, 3) == 0
|| WSTRNICMP((WCHAR *)"url" , wstrDataCurr, 3) == 0
|| WSTRNICMP((WCHAR *)"name" , wstrDataCurr, 4) == 0)
{
// do something...
}
else
{
// do something...
}

.........

Where is WCHAR defined, as far as i know its a windows datatype, have you redefined it in your program.

Where is WCHAR defined, as far as i know its a windows datatype, have you redefined it in your program.

> if( WSTRNICMP((WCHAR *)"tel" , wstrDataCurr, 3) == 0
"tel", by default, is of "char*" type (or const char* in C++).
You can not just think of casting "tel" into WCHAR* or whatever widechar data type you are using.
(WCHAR*)"tel" is actuall interpreted something like this:
index: 0 1 2 3
value: | t | e | l | \0
The string expected by WSTRNICMP is actually like this:
index: 0 1 2 3 4 5 6 7
value: | o | t | o | e | o | l | o | \0 |
Please use STRTOWSTR() for converting "tel" to widechar and then use it.
-Viren

> if( WSTRNICMP((WCHAR *)"tel" , wstrDataCurr, 3) == 0
"tel", by default, is of "char*" type (or const char* in C++).
You can not just think of casting "tel" into WCHAR* or whatever widechar data type you are using.
(WCHAR*)"tel" is actuall interpreted something like this:
index: 0 1 2 3
value: | t | e | l | \0
The string expected by WSTRNICMP is actually like this:
index: 0 1 2 3 4 5 6 7
value: | o | t | o | e | o | l | o | \0 |
Please use STRTOWSTR() for converting "tel" to widechar and then use it.
-Viren

Or you can use L"tel" to convert it during compile time. Just by casting you can't make to UTF16.

Or you can use L"tel" to convert it during compile time. Just by casting you can't make to UTF16.

but be beware of rvct - recent version of rvct does not quite like that syntax.

but be beware of rvct - recent version of rvct does not quite like that syntax.