I have been looking around on how to bring a string,
const char* output = "ヽ(⌐■_■)ノ♪♬";
to the clipboard.
SetClipboardData(CF_UNICODETEXT, hMem);
I have tried MultiByteToWideChar, but I have gotten only noise and also conflicting claims that you cannot save UTF-16LE to clipboard (wchar_t). Honestly I am just confused. A direction or code sample would be great.
Windows uses UTF-16LE. The string should be created with
L
prefix. To use UTF8 you can declare the string withu8
prefix. For example:Then you have to use
MultiByteToWideChar
to convert UTF8 to UTF16 and use in WinAPI. Note that to useu8
you need newer compilers like VS2015.It's easier to use UTF16 in the first place. For example: