I am trying to convert a string from ANSII to Wide char. I am using CA2W(string,CP_UTF8) which internally uses MultiByteToWideChar.
While debugging it shows that MultiByteToWideChar converts ° degree symbol to �.
Any suggestions on how to resolve this?
MultiByteToWideChar converts from a given encoding to UTF-16 (ie wide char). You need to make sure that you specify the correct encoding of the source, which probably is NOT UTF-8.
Due to the way UTF-8 is encoded anything over ASCII 0x7f indicates that the BYTE is part of a multi-byte character sequence and unless that sequence is correctly specified will result in a ‘?’. More information on the encoding of multi-byte sequences can be found here:
http://en.wikipedia.org/wiki/UTF-8
Basically, your source encoding is probably based on the current code page of the system and so you need to specify CP_ACP when calling MultiByteToWideChar.