我知道,如何将新线特性(LF)仅仅写到幼年产出(见下面的测试法),但总是在终端会议所展示的案文的正确形象中转换成欧阵。
我在互联网上发现了几个类似的问题,其中包括关于中继流的2个问题:C++ - 标准产出的新线而不是Windows平台CR+LF的新线和,但它们和我发现有帮助的其他人都没有。
Here is a small example, to show you what I want:
#include <stdio.h>
// possibly other includes, defines and more
void main(void) {
printf("Hello
"); // Where
is a normal Line Feed Character (0x0A)
printf("Hi");
}
The expected output
Hello
Hi
The actual output
Hello
Hi
这是因为,线性饲料的特性被线性饲料和板块回收器所取代。 我尝试了好几件事情来消除这种行为,包括上述联系中提到的想法和更多的想法。
www.un.org/Depts/DGACM/index_spanish.htm 我预计,终端应用程序“
Test Code (which also doesn t work)
唯一具有某种视觉效果的是最后一次测试,但是它完全可以排除所有特殊性,因此,新路线只是新线,而是一种替代。 (Which不是应该发生的事情)
#include <iostream>
#include <Windows.h>
#include <CommCtrl.h>
#include <io.h>
#include <fcntl.h>
int main() {
char lineFeed[] = { 0x0A, 0x00 };
char carriageReturn[] = { 0x0D, 0x00 };
// Testing without any settings changed
printf("hello there
");
printf("hi");
printf(&carriageReturn[0]);
printf("sus");
printf(&lineFeed[0]);
printf("mogus");
printf("hey world
sup
hi");
// Toggling what [ENTER] does in regards to edit controls
HWND consoelWindow = GetConsoleWindow();
SetWindowLongA(consoelWindow, ES_WANTRETURN, GetWindowLongA(consoelWindow, ES_WANTRETURN) ^ ES_WANTRETURN);
printf("hello there
");
printf("hi");
printf(&carriageReturn[0]);
printf("sus");
printf(&lineFeed[0]);
printf("mogus");
printf("hey world
sup
hi");
// Disabling insertion of soft line-break characters
SendMessage(consoelWindow, EM_FMTLINES, FALSE, 0);
printf("hello there
");
printf("hi");
printf(&carriageReturn[0]);
printf("sus");
printf(&lineFeed[0]);
printf("mogus");
printf("hey world
sup
hi");
// Enabling insertion of soft line-break characters
SendMessage(consoelWindow, EM_FMTLINES, TRUE, 0);
printf("hello there
");
printf("hi");
printf(&carriageReturn[0]);
printf("sus");
printf(&lineFeed[0]);
printf("mogus");
printf("hey world
sup
hi");
// Setting output mode to binary. That way
will not be replaced with
by the C standard library implementation
_setmode(1, _O_BINARY);
_setmode(_fileno(stdout), O_BINARY);
_setmode(_fileno(stdin), O_BINARY);
printf("hello there
");
printf("hi");
printf(&carriageReturn[0]);
printf("sus");
printf(&lineFeed[0]);
printf("mogus");
printf("hey world
sup
hi");
// Disabling processed output, aka "Backspace, tab, bell, carriage return, and line feed characters are [not] processed"
HANDLE outputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode = 0;
BOOL ret1 = GetConsoleMode(outputHandle, &mode);
mode ^= ENABLE_PROCESSED_OUTPUT;
BOOL ret2 = SetConsoleMode(outputHandle, mode);
ret2 = ret2;
printf("Hello There2
");
printf("hi");
}
Feel free to provide links to helpful articles, sample code, more things I can test, links to documentation or other media. Or maybe an explaination what I did wrong.
Thank you for your time and answer.