Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENABLE_VIRTUAL_TERMINAL_PROCESSING skips null characters #8866

Closed
alabuzhev opened this issue Jan 23, 2021 · 2 comments
Closed

ENABLE_VIRTUAL_TERMINAL_PROCESSING skips null characters #8866

alabuzhev opened this issue Jan 23, 2021 · 2 comments
Labels
Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons.

Comments

@alabuzhev
Copy link
Contributor

Environment

Windows build number: 10.0.19041.746
Windows Terminal version (if applicable): No

Any other software? No

Steps to reproduce

Historically null characters in console output have been replaced with spaces by the host.
Now, when ENABLE_VIRTUAL_TERMINAL_PROCESSING is set, these characters are completely removed from the output instead.
It breaks screen output logic if the application relies on the previous behavior.

Compile and run the following code:

#include <windows.h>

int main()
{
	const wchar_t Str[] = L"ABC\0XYZ\n";

	const auto Out = GetStdHandle(STD_OUTPUT_HANDLE);

	const auto print = [&]
	{
		DWORD n;
		WriteConsole(Out, Str, ARRAYSIZE(Str) - 1, &n, {});
	};

	print();

	DWORD Mode;
	GetConsoleMode(Out, &Mode);
	SetConsoleMode(Out, Mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);

	print();
}

Expected behavior

ABC XYZ
ABC XYZ

Actual behavior

ABC XYZ
ABCXYZ
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jan 23, 2021
alabuzhev added a commit to FarGroup/FarManager that referenced this issue Jan 23, 2021
@skyline75489
Copy link
Collaborator

Related: #6265 , #8680

@zadjii-msft
Copy link
Member

Yea this is totally by design. ENABLE_VIRTUAL_TERMINAL_PROCESSING changes a whole bunch of other things about the way the console behaves too, this is just one part of it. If you want the console to act like a terminal, then you'll need to output text like you're connected to a terminal 😉

There's also #1825, #3015, #4171 all relevant in this space.

@zadjii-msft zadjii-msft added the Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons. label Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons.
Projects
None yet
Development

No branches or pull requests

3 participants