uE0B0 working in VSC Terminal but not cmd.exe

using System;
using System.Threading;
using System.Text;
using System.Runtime.InteropServices;

namespace App {
class Program {
[DllImport( "kernel32.dll", SetLastError = true )]
public static extern bool SetConsoleMode( IntPtr hConsoleHandle, int mode );
[DllImport( "kernel32.dll", SetLastError = true )]
public static extern bool GetConsoleMode( IntPtr handle, out int mode );

[DllImport( "kernel32.dll", SetLastError = true )]
public static extern IntPtr GetStdHandle( int handle );

static void Main() {
var handle = GetStdHandle( -11 );
int mode;
GetConsoleMode( handle, out mode );
SetConsoleMode( handle, mode | 0x4 );

Console.OutputEncoding = System.Text.Encoding.Unicode;


int width = Console.WindowWidth;
Console.WriteLine($"\x1b[48;2;0;206;209m\x1b[38;2;17;17;27m\uE0B0\x1b[38;2;0;150;240m \u2699 \x1b[38;2;255;128;128m\u26CA \x1b[39m axa@axa \x1b[0m\x1b[38;2;0;206;209m\x1b[48;2;255;215;0m\uE0B0 ~ \x1b[0m\x1b[38;2;255;215;0m\uE0B0");
Console.ResetColor();
}

}

}
using System;
using System.Threading;
using System.Text;
using System.Runtime.InteropServices;

namespace App {
class Program {
[DllImport( "kernel32.dll", SetLastError = true )]
public static extern bool SetConsoleMode( IntPtr hConsoleHandle, int mode );
[DllImport( "kernel32.dll", SetLastError = true )]
public static extern bool GetConsoleMode( IntPtr handle, out int mode );

[DllImport( "kernel32.dll", SetLastError = true )]
public static extern IntPtr GetStdHandle( int handle );

static void Main() {
var handle = GetStdHandle( -11 );
int mode;
GetConsoleMode( handle, out mode );
SetConsoleMode( handle, mode | 0x4 );

Console.OutputEncoding = System.Text.Encoding.Unicode;


int width = Console.WindowWidth;
Console.WriteLine($"\x1b[48;2;0;206;209m\x1b[38;2;17;17;27m\uE0B0\x1b[38;2;0;150;240m \u2699 \x1b[38;2;255;128;128m\u26CA \x1b[39m axa@axa \x1b[0m\x1b[38;2;0;206;209m\x1b[48;2;255;215;0m\uE0B0 ~ \x1b[0m\x1b[38;2;255;215;0m\uE0B0");
Console.ResetColor();
}

}

}
Should look sm like diz but its
No description
No description
41 Replies
mtreit
mtreit•7mo ago
You need the Powerline version of the font you use for your terminal
Deleted User 3t47rcvavy
I just installed Nerd Fonts but it prints a square in cmd.exe I also imported it
mtreit
mtreit•7mo ago
What font is your terminal set to use?
Deleted User 3t47rcvavy
Lucido Console as default one but I got a program that imports a custom .ttf file
mtreit
mtreit•7mo ago
Yeah just installing nerdfonts isn't sufficient, you need to change the font the terminal is using. You can just double-click the ttf file to install it.
Deleted User 3t47rcvavy
can't I do it using that script
mtreit
mtreit•7mo ago
Probably
Deleted User 3t47rcvavy
I literally mentione dthat I imported it into my console already
mtreit
mtreit•7mo ago
Are you using Windows Terminal?
Deleted User 3t47rcvavy
cmd.exe...
mtreit
mtreit•7mo ago
So cmd.exe is the program, but the terminal shell it's hosted in can be either Windows Terminal or conhost.exe. Conhost is the old crappy one, and Windows Terminal is thee new really good one.
Deleted User 3t47rcvavy
yes I know but IW ant it in cmd,exe
mtreit
mtreit•7mo ago
If you want conhost to work, you need to change your font to one that is a Powerline font. Like this.
mtreit
mtreit•7mo ago
No description
mtreit
mtreit•7mo ago
But why anyone would use conhost is beyond me. It sucks
mtreit
mtreit•7mo ago
When I run cmd.exe it opens in Winodws Terminal because I set it to be the default host:
No description
Deleted User 3t47rcvavy
i see hmm
mtreit
mtreit•7mo ago
Anyway, you just need to choose the right font Like in my screenshot I'm choosing the one with PL in the name so I get the Powerline symbols
mtreit
mtreit•7mo ago
Like that little github branch symbol comes from the PL font
No description
Deleted User 3t47rcvavy
oh dang it this is gonna be fun looks like no powerlines for now 🙂
mtreit
mtreit•7mo ago
What do you mean?
Deleted User 3t47rcvavy
that I was excited to make those powerlines you get me
mtreit
mtreit•7mo ago
Just install a Powerline font like Cascadia Code PL
Deleted User 3t47rcvavy
hold on lemme try
mtreit
mtreit•7mo ago
No description
Deleted User 3t47rcvavy
Where did u find Cascadia Code PL I'm looking for it
mtreit
mtreit•7mo ago
GitHub
GitHub - microsoft/cascadia-code: This is a fun, new monospaced fon...
This is a fun, new monospaced font that includes programming ligatures and is designed to enhance the modern look and feel of the Windows Terminal. - GitHub - microsoft/cascadia-code: This is a fun...
mtreit
mtreit•7mo ago
It's in the zip file along with all of the other variants
Deleted User 3t47rcvavy
u were right
No description
mtreit
mtreit•7mo ago
🎉
Deleted User 3t47rcvavy
Thank you so much man I really appreciate it
mtreit
mtreit•7mo ago
Now switch to Windows Terminal and PowerShell like a sane person 🙂
Deleted User 3t47rcvavy
I like to make CLI apps for cmd.exe idk why
mtreit
mtreit•7mo ago
I mean, PowerShell is going to be the same experience but just superior in almost every way.
Deleted User 3t47rcvavy
ye I get u
Deleted User 3t47rcvavy
great
No description
Deleted User 3t47rcvavy
oh by the way @mtreit how do I enable ANSI Escape codes using C#?
Chiyoko_S
Chiyoko_S•7mo ago
I remember writing this years ago
Chiyoko_S
Chiyoko_S•7mo ago
the code kinda looks cursed now why did I even use volatile there but basically, you call some weird windows API function to enable vt100 mode for the given console
Deleted User 3t47rcvavy
Thanks :))
Want results from more Discord servers?
Add your server
More Posts