How do I print UTF-8 from c++ console application on Windows

This should work: #include <cstdio> #include <windows.h> #pragma execution_character_set( “utf-8” ) int main() { SetConsoleOutputCP( 65001 ); printf( “Testing unicode — English — Ελληνικά — Español — Русский. aäbcdefghijklmnoöpqrsßtuüvwxyz\n” ); } Don’t know if it affects anything, but source file is saved as Unicode (UTF-8 with signature) – Codepage 65001 at FILE -> Advanced Save … Read more

Java gotoxy(x,y) for console applications

If by gotoxy(x,y), you want to reposition your cursor somewhere specific on the console, you can usually use VT100 control codes to do this. See http://www.termsys.demon.co.uk/vtansi.htm. Do something like char escCode = 0x1B; int row = 10; int column = 10; System.out.print(String.format(“%c[%d;%df”,escCode,row,column)); Which should move the cursor to position 10,10 on the console.

Masking password input from the console : Java

A full example ?. Run this code : (NB: This example is best run in the console and not from within an IDE, since the System.console() method might return null in that case.) import java.io.Console; public class Main { public void passwordExample() { Console console = System.console(); if (console == null) { System.out.println(“Couldn’t get Console … Read more

.NET Global exception handler in console application

No, that’s the correct way to do it. This worked exactly as it should, something you can work from perhaps: using System; class Program { static void Main(string[] args) { System.AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper; throw new Exception(“Kaboom”); } static void UnhandledExceptionTrapper(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject.ToString()); Console.WriteLine(“Press Enter to continue”); Console.ReadLine(); Environment.Exit(1); } } Do keep … Read more

Custom text color in C# console application?

The list found at http://msdn.microsoft.com/en-us/library/system.console.backgroundcolor.aspx I believe are the only supported colors in console. No hex allowed. Black DarkBlue DarkGreen DarkCyan DarkRed DarkMagenta DarkYellow Gray DarkGray Blue Green Cyan Red Magenta Yellow White EDIT Get the working project files off my public Repo https://bitbucket.org/benskolnick/color-console/ But on further investigation you can do a lot of work … Read more

.NET console application as Windows service

I usually use the following techinque to run the same app as a console application or as a service: using System.ServiceProcess public static class Program { #region Nested classes to support running as service public const string ServiceName = “MyService”; public class Service : ServiceBase { public Service() { ServiceName = Program.ServiceName; } protected override … Read more