Emojis are not displayed when using wide string output #16734

Open
opened 2026-01-31 05:21:15 +00:00 by claunia · 0 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:15 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16734