Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know how to get ASCII to work but you can use Unicode, to some degree, if you want to. It does require that the console be set to a true type font. </p> <p>Michael Kaplan's <a href="http://www.siao2.com/2010/04/07/9989346.aspx" rel="nofollow">article</a> 'Anyone who says the console can't do Unicode isn't as smart as they think they are' includes the code for this. </p> <p>I couldn't get his code to work directly but this worked for me as long as I ran it from a True Type Font Console. The article includes how to set it.</p> <pre><code>using System; using System.Runtime.InteropServices; namespace TestUnicode { class Program { public static void Main(string[] args) { string st = "\u0169\u0129\n\n"; IntPtr stdout = GetStdHandle(STD_OUTPUT_HANDLE); uint written; WriteConsoleW(stdout, st, st.Length, out written, IntPtr.Zero); } [DllImport("kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern bool WriteConsoleW(IntPtr hConsoleOutput, string lpBuffer, int nNumberOfCharsToWrite, out uint lpNumberOfCharsWritten, IntPtr lpReserved); internal static bool IsConsoleFontTrueType(IntPtr std) { CONSOLE_FONT_INFO_EX cfie = new CONSOLE_FONT_INFO_EX(); cfie.cbSize = (uint)Marshal.SizeOf(cfie); if(GetCurrentConsoleFont(std, false, ref cfie)) { return(((cfie.FontFamily &amp; TMPF_TRUETYPE) == TMPF_TRUETYPE)); } return false; } [DllImport("Kernel32.DLL", ExactSpelling = true)] internal static extern IntPtr GetStdHandle(int nStdHandle); [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] internal static extern bool GetCurrentConsoleFont(IntPtr hConsoleOutput, bool bMaximumWindow, ref CONSOLE_FONT_INFO_EX lpConsoleCurrentFontEx); internal struct COORD { internal short X; internal short Y; internal COORD(short x, short y) { X = x; Y = y; } } [StructLayout(LayoutKind.Sequential)] internal unsafe struct CONSOLE_FONT_INFO_EX { internal uint cbSize; internal uint nFont; internal COORD dwFontSize; internal int FontFamily; internal int FontWeight; fixed char FaceName[LF_FACESIZE]; } internal const int TMPF_TRUETYPE = 0x4; internal const int LF_FACESIZE = 32; internal const string BOM = "\uFEFF"; internal const int STD_OUTPUT_HANDLE = -11; // Handle to the standard output device. internal const int ERROR_INVALID_HANDLE = 6; internal const int ERROR_SUCCESS = 0; internal const uint FILE_TYPE_UNKNOWN = 0x0000; internal const uint FILE_TYPE_DISK = 0x0001; internal const uint FILE_TYPE_CHAR = 0x0002; internal const uint FILE_TYPE_PIPE = 0x0003; internal const uint FILE_TYPE_REMOTE = 0x8000; internal static IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload