简体   繁体   中英

How to print symbol “↑” using AfxMessageBox?

How can I print this symbol "↑" using AfxMessageBox() ?

I try to code it like this:

AfxMessageBox("↑");

After compiling, I got a strange symbol:

图片

Does AfxMessageBox() not support this symbol?

Your source file is likely saved as UTF-8. To work with MBCS string literals, your source file needs to be saved in the same charset that your OS user locale is set to. Unfortunately, not many charsets support this particular character, I think. Otherwise, you have to switch to Unicode.

If you can't switch the whole app to Unicode, then you can at least use MessageBoxW() instead, eg:

::MessageBoxW(NULL, L"↑", L"title", MB_OK);

Or

::MessageBoxW(NULL, L"\x2191", L"title", MB_OK);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM