Emojis are not displayed when using wide string output #16737

Closed
opened 2026-01-31 05:21:18 +00:00 by claunia · 2 comments
Owner

Originally created by @vitalyster on GitHub (Feb 10, 2022).

Windows Terminal version

1.11.3471.0

Windows build number

10.0.22000.493

Other Software

This example program display emoji correctly:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#include <iostream>
#include <string>

int main() {
	SetConsoleOutputCP(CP_UTF8);
	std::cout << "😀" << std::endl;
	return 0;
}

However, "wide-string" version does not display emojis correctly:

#include <iostream>
#include <string>
#include <io.h>
#include <fcntl.h>

int main() {
	_setmode(_fileno(stdout), _O_U8TEXT);
	std::wcout << L"\xD83D\xDE00" << std::endl;
	return 0;
}

This version show garbage on the Windows Terminal, but if I redirect output to file like test.exe > file.txt then file will have correct emoji symbol. So I'm pretty sure Windows Terminal should support that too.

Steps to reproduce

Compile test programs from Developer Command Prompt (Visual Studio) like cl /EHsc test1.cpp and cl /EHsc test2.cpp and run test1.exe and test2.exe. Also run test2.exe > file.txt to make sure file output works.

Expected Behavior

Both test1 and test2 should output emoji to the console:

image

Actual Behavior

Widestring version does not output emoji to the WT:
image
But it works when output is redirected to a file:
image

Originally created by @vitalyster on GitHub (Feb 10, 2022). ### Windows Terminal version 1.11.3471.0 ### Windows build number 10.0.22000.493 ### Other Software This example program display emoji correctly: ```cpp #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <iostream> #include <string> int main() { SetConsoleOutputCP(CP_UTF8); std::cout << "😀" << std::endl; return 0; } ``` However, "wide-string" version does not display emojis correctly: ```cpp #include <iostream> #include <string> #include <io.h> #include <fcntl.h> int main() { _setmode(_fileno(stdout), _O_U8TEXT); std::wcout << L"\xD83D\xDE00" << std::endl; return 0; } ``` This version show garbage on the Windows Terminal, but if I redirect output to file like `test.exe > file.txt` then file will have correct emoji symbol. So I'm pretty sure Windows Terminal should support that too. ### Steps to reproduce Compile test programs from Developer Command Prompt (Visual Studio) like `cl /EHsc test1.cpp` and `cl /EHsc test2.cpp` and run `test1.exe` and `test2.exe`. Also run `test2.exe > file.txt` to make sure file output works. ### Expected Behavior Both test1 and test2 should output emoji to the console: ![image](https://user-images.githubusercontent.com/1052407/153436343-7cccba9c-3139-4ce9-8905-753a92088fc9.png) ### Actual Behavior Widestring version does not output emoji to the WT: ![image](https://user-images.githubusercontent.com/1052407/153436404-1469af1b-ab0d-4260-a1c3-5f4b1df45f4a.png) But it works when output is redirected to a file: ![image](https://user-images.githubusercontent.com/1052407/153437925-b5883279-c233-4ce1-baa4-0ef28fe72285.png)
claunia added the Issue-BugNeeds-Tag-Fix labels 2026-01-31 05:21:18 +00:00
Author
Owner

@DHowett commented on GitHub (Apr 26, 2023):

I'm sorry we let this one fall so far down the queue. I believe you need to set _O_U16TEXT on stdout to make the UTF-16 surrogate pair case work through wcout:

image

@DHowett commented on GitHub (Apr 26, 2023): I'm sorry we let this one fall so far down the queue. I believe you need to set `_O_U16TEXT` on stdout to make the UTF-16 surrogate pair case work through `wcout`: ![image](https://user-images.githubusercontent.com/189190/234718995-92202227-6e94-43ac-8ac8-30949b934ded.png)
Author
Owner

@AnyOldName3 commented on GitHub (May 27, 2025):

This is one of the top Google results for this, but the solution presented is no longer working, suggesting it might have regressed. I see two placeholders as if I'd printed unpaired surrogates or the font didn't support the character, but printing the same string in other ways works fine:

Image

Is there an extra step required these days or should I report a bug?

@AnyOldName3 commented on GitHub (May 27, 2025): This is one of the top Google results for this, but the solution presented is no longer working, suggesting it might have regressed. I see two placeholders as if I'd printed unpaired surrogates or the font didn't support the character, but printing the same string in other ways works fine: ![Image](https://github.com/user-attachments/assets/c3601099-38d6-49ff-9eef-9224b3eb51c3) Is there an extra step required these days or should I report a bug?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16737