Does anyone have an idea why these console colors aren't coming out properly? Some of them work and some come out as junk.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace daniweb.capp
{
  class Program
  {
    static void Main(string[] args)
    {
      const string s =
      "0020002000200020007c007c003a003a007c003a007c007c002000200020002e" +
      "002d002d002d002d002d002d002d002d002c000d000a0020002000200020007c" +
      "003a007c007c003a007c003a007c002000200020007c005f005f005f005f005f" +
      "005f005f0020002f00200020002000200020002000200020002e002d002e000d" +
      "000a0020002000200020007c007c003a003a007c003a007c007c0020002e0022" +
      "006000200020005f005f005f0020002000600022002e0020002000200020007b" +
      "005c00280027007600270029002f007d000d000a0020002000200020005c005c" +
      "005c002f005c002f002f002f003a00200020002e002700600020002000200060" +
      "0027002e00200020003b005f005f005f005f0060002800200020002000290027" +
      "005f005f005f005f000d000a00200020002000200020005c003d003d003d003d" +
      "002f00200027002e002f00200020006f002000200020006f00200020005c007c" +
      "007e00200020002000200020005e002200200022005e002000200020002f002f" +
      "000d000a002000200020002000200020005c005c002f002f002000200020007c" +
      "00200020002000280029002900290020002e00200020007c0020002000200053" +
      "006500610073006f006e002700730020002000200020005c000d000a00200020" +
      "00200020002000200020007c007c00200020002000200020005c00200060002e" +
      "005f005f002e002700200020002f007c00200020002000200020002000200020" +
      "002000200020002000200020002f002f000d000a002000200020002000200020" +
      "0020007c007c002000200020005f007b00600060002d002e005f005f005f002e" +
      "002d0027005c007c002000200020004700720065006500740069006e00670073" +
      "002000200020005c000d000a0020002000200020002000200020007c007c0020" +
      "005f002e002200200060002d002e005f005f005f005f002e002d00270060007c" +
      "0020002000200020005f005f005f0020002000200020002000200020002f002f" +
      "000d000a0020002000200020002000200020007c007c00600020002000200020" +
      "0020002000200020005f005f0020005c002000200020007c005f005f005f002f" +
      "002000200020005c005f005f005f005f005f005f005f005c000d000a00200020" +
      "002000200020002e0022007c007c002000200020002000200020002000200028" +
      "005f005f00290020005c0020002000200020005c007c00200020002000200020" +
      "002f000d000a0020002000200020002f0020002000200060005c002f00200020" +
      "00200020002000200020005f005f002000200020007600760076007600760027" +
      "005c005f005f005f002f000d000a0020002000200020007c0020002000200020" +
      "0020007c0020002000200020002000200028005f005f00290020002000200020" +
      "0020002000200020007c000d000a00200020002000200020005c005f005f005f" +
      "002f005c00200020002000200020002000200020002000200020002000200020" +
      "002000200020002f000d000a0020002000200020002000200020007c007c0020" +
      "0020007c00200020002000200020002e005f005f005f002e0020002000200020" +
      "0020007c000d000a0020002000200020002000200020007c007c00200020007c" +
      "0020002000200020002000200020007c0020002000200020002000200020007c" +
      "000d000a0020002000200020002000200020007c007c002e002d002700200020" +
      "00200020002000200020007c00200020002000200020002000200027002d002e" +
      "000d000a0020002000200020002000200020007c007c00200020002000200020" +
      "00200020002000200020007c0020002000200020002000200020002000200020" +
      "0029000d000a0020002000200020002000200020007c007c002d002d002d002d" +
      "002d002d002d002d002d002d0027002d002d002d002d002d002d002d002d002d" +
      "0027000d000a000d000a005400680069007300200068006100730020006e006f" +
      "007400680069006e006700200074006f00200064006f00200077006900740068" +
      "00200063006f006e0073006f006c006500200063006f006c006f007200730020" +
      "003a005000200050006f0073007400200073006f006d0065007400680069006e" +
      "0067002000660075006e006e00790020006200610063006b0021000d000a004d" +
      "00650072007200790020006300680072006900730074006d0061007300200044" +
      "0061006e00690077006500620021000d000a";

      StringBuilder sb = new StringBuilder();
      sb.Capacity = Convert.ToInt32((s.Length / 4));
      for (int i = 0; i < s.Length; i += 4)
      {
        sb.Append((char)Int16.Parse(s.Substring(i, 4), System.Globalization.NumberStyles.AllowHexSpecifier));
      }
      Console.WriteLine(sb.ToString().Trim());
      Console.ReadKey();
    }
  }
}
jonsca commented: :) +1
ddanbe commented: Very good and original! +6

Recommended Answers

All 5 Replies

Hi Scott!
This deserves definitly rep next day, because this day I already did!!!
I was wondering, Scott needing help? You got me there:-O
You even managed to put your avatar in a console app, great!
Happy New Year! :)

Don't know why you use Trim on line 71, because it trims of the first 4 spaces ('0020') did you mean TrimEnd?
Anyway, I got this:

using System;

namespace ConsoleApplication3
{
        class Program
        {
            static void Main(string[] args)
            {
                const string Danny =
                    ".................................,,:~:~:,,,,,,,,,,,,.,,.....,,..,..............." +
"..............................,:~~:~~:~:~::,,,,,:,,,,,,.,,,....................." +
"............................~::~~~:::==,,,,:,,~,,,,,,,.,,,......................" +
".........................~~+~=~:~::~,~,:~::~~~:~:,,:,,,,,,,....................." +
    "......................,:=~:~=~~:~~::~:::~~~::~::::::~~:,,,:,.::................." +
    ".....................:=~==~~~~~:::~:~:====~~~~=::=======:,,,,....,.............." +
    "..................,~==~=====~=~~~========~:===============~=,,~,,,...,.,........" +
    ".................~~=~~===~~=~~~=====+===~==================:~,,~:,,,,,,,........" +
"...............,:=~~==~====~~=====+==~======+++++===========~~,,,::,.,.........." +
"...............:=:~=~::~==:==~==++==~==?==??=====++===========:,,,,,,,,,.......," +
"..............~=:=~,~~~~:~==~?=?~===???+=?+??+???++===========~~~:~~,,=,,..,...," +
"............,:~:~,,,~:::~~:=:==+==~=+?????????+=+=+============::,,~~,~~,,.,,..," +
    "............=:,::,,~::::~~~~==~+~=~?+?+????????+~==============~::::~~~=~....,.," +
    ".......,::~:~~:,:~::====:~:+=:~:===++==?=++?=~==~::~:~:~::======::~,~~:,~:,.,..." +
    "~,.....,:::,::::~~+=?+++++?++=:+I~=I???=:~======:::::::::~~~:===::::,~::~,,,...." +
    "~,.....,,:,:::~::==++I7??II+?I++=?:~==~::,:===~::~=~===~~~::~:::::~:,,:,:=..,..." +
":,.....,,,,:,::,==++II7?77II7?++========~::==?++++??++?++=::~~:~:~~:,,=:,,,....." +
".......,~,,,,~:~:==?77+III??I+?+=======:?~=~~=~=?+++++=~~==~~=~::,,~,,::,,,,,.,." +
"....,..,?,~,,~:::====I=I?+7I?+?========~?~======+++?+?+++?===~::~::~=,:~,,,,.,,." +
",,~,....,~~,:~~::==~======+++?=:=======:~:=????II7?77?I++I=~~~:::?:~,~:~,,,,,,.." +
    ".=.,,,.,,::====:=======+??+++~:===+====:~,=++??I77II++?7?==+=~:::=,,,~~:,,,,,,.." +
    ".,,,,,..:~,::~::==~~=++?===~:~========~~~:=?+?I7II?+I?+==+===~:::+,.,:~~,,,...,," +
    ",,~.,,,.,,,==~=====+=+=~++?============~~~:~??++++?++I7+==~:~~:::::,,,:,,,,....." +
    "~,,,.,:,,,:===================+++======~~==:~=++++??+++++==~=:=~=:~,,,:~,,,.,..." +
",,:~~::.,,:======++=+++++====++???=====~~~===:===?+++?+??~=~===:~~:,,:::,,,,,..." +
"::~~:,,,::=========+++==+=====+???=====:::=========+==~~~:~::~==::~,,.,:~~,,...." +
"~~~:::,,~===========+=+??=============::~~===+==+=========+====~::~,,,~:,,~,...." +
"~~:::,:,:========+++=++?+==:========~::~:~==??+=+=+========~~~~~::~:.,:~,:,,...." +
    "~::~::,~========++++=++?==~:,:==~~~~,,:==~:+?+??+++============::::,:,,,,~,,...." +
    "~~:::::==========+=??+=?=:::::~::::,,..:==:=????+?++============~~:~,:,:,:~,,,.." +
    "~~:::,:=========+++??====~:::~~+=:~~~~:==~~=++????++++=========~~:,:,~~~,,=::,.." +
    ":,,,,::=========+=?===~:~::~~:::=~::::::=~:=+=???+++=+=========::~~~=,=~,,:~,..." +
",.,.::========+===:~::~::~:~::~=:~~~~::::~==+????+==+=+======~~~~~::,,,,,,:=,..." +
"..,,,:========~::~~::::~~~~~::==~::::~~:~~====+?++==++========~:~::::~,,,.,:,,.." +
"..,,~==========:~:~~:~==~+=======::~:~:~:::===+?++=++========~:~:::~,,,,,,~,,,.." +
"..,,~~=======::~:::~=========?+++==~~:~:::~::===+==+==========~:~:~~,,,,,,,,...." +
    "...::======~:=~::::~==================~::~,~~::==++===========~:~,~~:,,,,:,=...." +
    ".,,~:======~~:::~~=================~~==::::~,~~~~=============~~,,~,,,,,,~,,...." +
    ".,:~:======~:~:=====~~:====:==========~~:~~:::::=============~~:,,~,,,,,,~,:...." +
    ".,,:~=====:========~::~====~=:=====~:===:::::~~~:============::,:,:,,,,.,:=,,..." +
".,,::==================:==:=~=:===:::===~:::::::::==========~:::~,,,.,,.,,::...." +
".,,~~:=~:=~==~========::~~:~~:=:===~~:===::::::~~:==========:~:,,,,:,,,,,,,,,..." +
".,:::~=~=====~=========~==~=~=~~==========~~==~:==~=========~~::,,,,,.~,,,,....." +
":,,,,~~=~~~=~===~~==============+=======~=+===~~~===========+~::,,,,,,.,,,.,...." +
    ".,,,~:=~~=~==========================~======~~===~========~=~~~,:.,.,,,,,.,....." +
    ".,,,~::===============================~===~~~===~====+==~~~~:~~,,,.,,,.,,.,,,..." +
    "..,,=~:~~::=~~~==========+==+==========~====~====~==~===~~::~~,.,..,=,,,,...,..." +
    "...,~~~:==~==~==================~=======+==~========::~::~~:,,,,,,.,,,,,,.,,,,.." +
"...:,::~:~======~~~:~~~~~~~=~=~~~~~~~=~~=~~~==~~==~::::::::,,,.,....,..,,,...,..";
                Console.SetWindowSize(80, 50);
                Console.WriteLine(Danny);
                Console.ReadKey();
            }
        }
}
commented: Very nice! ASCII art lives! +1

>>Don't know why you use Trim on line 71, because it trims of the first 4 spaces ('0020') did you mean TrimEnd?
Yes, I did :(

I can't recognize the picture in your last post (c1.png). Did the snowman turn out from my original code snippet on your end? I don't know much about running c# apps in other culture settings so I was wondering if it would turn out. Good call on the .Trim() -- I messed up the first line.

It was just a quick and dirty thing. If you move far enough from the screen, you should recognise my avatar. I know, nothing very fancy and not something as good as your snowman. But as they say: "You can't win 'em all!":(
EDIT: still too early to give rep!

Ah ha! You're right about moving back from the screen :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.