String literals are converted by the compiler from the source encoding to the execution encoding. The execution encoding you're using evidently can't handle that character so it's replaced with '?'.
You need to either choose a different execution encoding if your compiler supports that (gcc does with the flag -fexec-charset
) or trick compilers that don't support that (such as Visual Studio) into not doing this conversion by lying to it about what the source encoding is.
You can lie to VS about the source encoding by setting your source code to UTF-8 without a signature. VS will assume the source encoding is the system's "encoding for non-Unicode programs" which is the same as it uses for the execution encoding. Since it will believe that the encodings are the same it will not perform any conversion and the string literal will be UTF-8. You'll have to be careful to avoid anything else in your source code where the compiler needs to know the correct encoding though. For example if you do this then wide string literals will not be converted correctly.
Another solution would be the new C++11 UTF-8 string literals: u8"Hello I’ve to go"
. These are converted by the compiler from the source encoding to UTF-8, rather than to the execution encoding. Unfortunately Visual Studio does not yet support UTF-8 string literals.
In a comment above you say "In my real project, this value is read from the file name." This indicates a completely different problem than the one demonstrated in your question. Solving this will require details about how exactly you get the file name.
Showing you how to fix the code that you posted will not fix your actual problem, because the problem in the code you posted and your actual problem are different. There will not be a 'generic solution' that solves both.