Comparing a character string to LPWSTR
-
Hi all, I need to compare 2 strings,one is a simple character string and the other is a LPWSTR value.How can I do it.Is there any type conversion available. Thanks Abhishek. Learning is a never ending process of Life.
-
Hi all, I need to compare 2 strings,one is a simple character string and the other is a LPWSTR value.How can I do it.Is there any type conversion available. Thanks Abhishek. Learning is a never ending process of Life.
You will need to convert one of the strings into the same format as the other. Which one you choose does not matter. Use one of these functions: MultiByteToWideChar WideCharToMultiByte
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life! -
You will need to convert one of the strings into the same format as the other. Which one you choose does not matter. Use one of these functions: MultiByteToWideChar WideCharToMultiByte
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!Isn't it best to convert the single-byte to wide-format? If conversion from wide- to single-byte format looses information (because some widechars are not representable), the strings might match after conversion, even if they don't actually match... No?
-
Hi all, I need to compare 2 strings,one is a simple character string and the other is a LPWSTR value.How can I do it.Is there any type conversion available. Thanks Abhishek. Learning is a never ending process of Life.
example:
USES_CONVERSION;
LPCSTR s1 = "Hello World!";
LPCWSTR s2 = L"Hello World!";int i = _tcscmp(A2CT(s1), W2CT(s2));
There is other ways, but more complicated. Michel It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard